mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-17 22:34:43 +08:00
fix(docs): use window.execScript instead of window.eval on IE
IE's window.eval doesn't execute in the global context, so we have to use window.execScript instead which works like window.eval on normal browsers. However execScript throws an exception when an empty string is passed in, so I created a workaround with a workaround.
This commit is contained in:
@@ -56,8 +56,13 @@
|
||||
element.append(tabs);
|
||||
|
||||
var script = (exampleSrc.match(/<script[^\>]*>([\s\S]*)<\/script>/) || [])[1] || '';
|
||||
|
||||
try {
|
||||
window.eval(script);
|
||||
if (window.execScript) { // IE
|
||||
window.execScript(script || '"stupid IE!"'); // IE complains when evaling empty string
|
||||
} else {
|
||||
window.eval(script);
|
||||
}
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user