[jQuery] weird error in globalEval

If I change the first line to
var head = document.documentElement,
it all works fine.In IE (but not in firefox) i suddenly got a ‘fatal’ error in globalEval; wrong argument passed in the last line, that says head.removeChild (script)..

In order to get things working again, i’ve had to make a small workaround:

globalEval: function( data ) {
	data = jQuery.trim( data );if ( data ) {

		// Inspired by code by Andrea Giammarchi
		// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html

		var head = document.getElementsByTagName("head")[0] || document.documentElement,
		script = document.createElement("script");
		script.type = "text/javascript";

		if ( jQuery.browser.msie )
			script.text = data;
		else
			script.appendChild( document.createTextNode( data ) );

		head.appendChild( script );

		try {
			head.removeChild( script );
		}
		catch (e) {
		}

	}

},

If I change the first line to “var head = document.documentElement” it all works fine too

Leave a comment

Please be polite and on topic. Your e-mail will never be published.

You must be logged in to post a comment.