[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 =
myIframe.contentDocument.getElementsByTagName("head").item(0)

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

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
called.

Does anyone have any ideas?

Thanks,
Gareth




		
___________________________________________________________ 
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. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 


More information about the Project_owners mailing list