jQuery.globalEval()
jQuery.globalEval( code )
描述: 在全局范圍下執(zhí)行一些JavaScript代碼。
-
version added: 1.0.4jQuery.globalEval( code )
code用來執(zhí)行的JavaScript代碼。
此方法的表現(xiàn)不同于正常使用的JavaScript eval(),因為它全局范圍下執(zhí)行(這對加載外部動態(tài)腳本很重要)。
Example:
Execute a script in the global context.
function test(){
jQuery.globalEval("var newVar = true;")
}
test();
// newVar === true