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:
Igor Minar 2011-09-06 13:59:27 -07:00
parent fc5cda2f72
commit 2d489ff936

View file

@ -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);
}