Skip to content

Instantly share code, notes, and snippets.

@devfred
Created May 18, 2012 16:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devfred/2726280 to your computer and use it in GitHub Desktop.
Save devfred/2726280 to your computer and use it in GitHub Desktop.
javascript: Evaluate a script in a global context
// Evaluates a script in a global context
// Workarounds based on findings by Jim Driscoll
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
// pulled from jquery.core source
var globalEval = function( data ){
if ( data ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data );
})( data );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment