Best not to use a string, but an anonymous function instead:
window.setTimeout(function () {
winId.document.write(
'<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript"></script>\n'
);
}, 10);
Using strings in setTimeout and setInterval is closely related to eval()
, and should only be used in rare cases. See http://dev.opera.com/articles/view/efficient-javascript/?page=2
It might also be worth noting that document.write()
will not work correctly on an already parsed document. Different browsers will give different results, most will clear the contents. The alternative is to add the script using the DOM:
window.setTimeout(function () {
var winDoc = winId.document;
var sEl = winDoc.createElement("script");
sEl.src = "../js/tiny_mce/tiny_mce.js";
winDoc.getElementsByTagName("head")[0].appendChild(sEL);
}, 10);