Dan06 Posted December 15, 2008 Share Posted December 15, 2008 I have an iframe and when it loads I want it to run js code from a file which is linked to the parent document. Currently, I get an error message stating: parent.ImgUpload is not a function The iframe html code is (simplified): <html> <head> <script src="..." type="text/javascript"></script> </head> <body> <iframe name="imgUploadFrame" id="imgUploadFrame"></iframe> </body> </html> The js code in the iframe that is supposed to run the js code from the parent is: window.onload = function() { parent.ImgUpload(); } Help appreciated. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted December 15, 2008 Share Posted December 15, 2008 what is the SRC for the iframe? are both the parent and iframe on the same server? Quote Link to comment Share on other sites More sharing options...
Dan06 Posted December 15, 2008 Author Share Posted December 15, 2008 The src is for the parent and it contains the js function - ImgUpload(). Yes, both the parent and iframe are on the same server. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted December 15, 2008 Share Posted December 15, 2008 using the following in FireFox works fine... <html> <head> <script src="script.js" type="text/javascript"></script> </head> <body> <iframe name="imgUploadFrame" id="imgUploadFrame" src="frame.php"></iframe> </body> </html> <html> <script> window.onload = function() { parent.ImgUpload(); } </script> <body> Hello World! </body> </html> function ImgUpload ( ) { alert('hi'); } Quote Link to comment Share on other sites More sharing options...
Dan06 Posted December 15, 2008 Author Share Posted December 15, 2008 I found the problem; it was with firefox's add-on firebug. I have anther js file that onload executes two POSTs. That for some reason causes an error in firebug, which results in the iframe code not running. Thanks for the help; I appreciate it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.