Simply talk about how to eval a code globally.
var x = 1; (function () { eval (' var x = 123; ');}) (); Console.log (x);
This code gets 1 instead of 123.
There are several ways to get eval to execute code that is global.
var x = 1; (function () { window.eval (' var x = 123; ');}) (); Console.log (x);
This way the standard browser can get 123 and ie6-8 is still 1
The same for example
var arr = [0,0,0,0,0,0];(function () { var arr = [1,1,1,1,1,1]; var _eval = eval; Window.eval (' arr[0] = 123; '); Eval.call (null, ' arr[1] = 123; '); _eval (' arr[2] = 123; '); (0,eval) (' arr[3] = 123; ');}) (); Console.log (arr);
0,1 does not seem to support ie8-2,3 seemingly does not support ie7-
The bottom line is that compatibility is a problem anyway.
But there is a execScript under IE very good.
var x = 1; (function () { (!-[1,]? execscript:eval) (' var x = 123; ');}) (); Console.log (x);
This is basically fully compatible.
Well, share this little bit of knowledge today.