// If the type is "script", eval it in global context
if ( type == "script" )
- (new Function( data ))();
+ jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
if ( this.src )
jQuery.ajax({ url: this.src, async: false, dataType: "script" });
else
- (new Function( this.text || this.textContent || this.innerHTML || "" ))();
+ jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
} else
fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
});
elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
},
+ // Evalulates a script in a global context
+ // Evaluates Async. in Safari 2 :-(
+ globalEval: function( data ) {
+ data = jQuery.trim( data );
+ if ( data ) {
+ if ( window.execScript )
+ window.execScript( data );
+ else if ( jQuery.browser.safari )
+ // safari doesn't provide a synchronous global eval
+ window.setTimeout( data, 0 );
+ else
+ eval.call( window, data );
+ }
+ },
+
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
},