[Project_owners] Adding a script to an iframe

Gareth Hunt gareth-hunt at rocketmail.com
Wed Feb 28 20:02:57 PST 2007

Hi all,

I have an iframe in a xul document that I need to add a javascript
reference to on the fly.  I am adding the script using:

var myIframe = document.getElementById("myIframe")
var head =

var script = myIframe.contentDocument.createElement("script")
script.type = "application/x-javascript"
script.src = "chrome://app/content/my.js"

This follows an example at:
http://www.dhtmlcentral.com/tutorials/tutorials.asp?id=11 . The
difference is that I am attempting to add the script to an iframe
contained within a xul document.

If I examine the iframe DOM after the insertion, the script is there in
the source, but the functions in the script are not available when

Does anyone have any ideas?


What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the Yahoo! Mail Championship. 

More information about the Project_owners mailing list