Created
May 18, 2012 16:38
-
-
Save devfred/2726280 to your computer and use it in GitHub Desktop.
javascript: Evaluate a script in a global context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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