[Javascript] Dynamically adding script tags, IE.

liorean liorean at f2o.org
Wed Jan 14 10:52:25 CST 2004


Hakan M. wrote:
> Cheers.
> I'm having a problem with dynamic loading of scripts. We have to do it a 
> bit ugly, using document.body.innerHTML to add strings containing 
> '<script src="blabla" type="text/javascript"></script>'. There is a 
> working solution (running over a list of sources and assigning the 
> source to an existing script tag) but we can't use that.

There's another solution. Have a look at 
<http://liorean.web-graphics.com/bookmarklets/bookmarklet.js>, which is 
the method I use in my bookmarklets to load external JavaScripts.

In iem you'll ahve to write the source of the script tag to an element. 
In iew you can create one dynamically using the DOM.

> Anybody with hardcore insight in why IE behave this way?

No, not into this, I'm afraid. Dynamic reparsing is something all 
browsers have been earlier or are currently bad at. Even Mozilla.

-- 
liorean <mailto:liorean at user.bip.net>

ViewStyles, ViewScripts, ToggleStyles and GraphicsInfo bookmarklets and 
Theme Switcher, Cookies Handler scripts:
<http://liorean.web-graphics.com/>




More information about the Javascript mailing list