.josh Posted April 21, 2009 Share Posted April 21, 2009 Okay, so here's the problem. I have a page with links on it. Also, on this page, I have a div tag like this: <div id='rc1'></div> When You click on a link on the page, I have a function called in an onclick. The function looks like this: function goAction(mBox, tUrl) { document.getElementById('rc1').innerHTML = '<iframe scrolling="no" src="convTrack/' + mBox + '.html" width="1" height="1" marginheight="0" marginwidth="0" frameborder="0"></iframe>'; sleep(1); location.href = tUrl; } So the idea is to insert an iframe into the div. The iframe does get written into rc1's innerHTML. The path/to/file is correct (I used alert to verify all this). So here's the thing: The src being loaded by the iframe looks like this: <html> <head> <script language="javascript" src="../mbox.js"></script> </head> <body> <div class="mboxDefault"></div> <script language="javascript"> mboxCreate(); </script> </body> </html> include path for mbox.js is okay, checked to make sure. So the problem is that when I do all this, mboxCreate(..) is not firing off. Now, in goAction, after I assign the iframe to rc1's innerHTML, if I were to for instance, do this: alert(document.getElementById('rc1').innerHTML); or this: document.write(document.getElementById('rc1').innerHTML); it will fire off. But I obviously do not want to be doing that. So my question is, why is it not firing off? Am I overlooking something? Link to comment https://forums.phpfreaks.com/topic/155076-function-not-executing-inside-iframe/ Share on other sites More sharing options...
markjoe Posted April 21, 2009 Share Posted April 21, 2009 At first glance, isn't location.href = tUrl; going to unload the page (parent of the iframe) and destroy the iframe anyway? Link to comment https://forums.phpfreaks.com/topic/155076-function-not-executing-inside-iframe/#findComment-815726 Share on other sites More sharing options...
markjoe Posted April 21, 2009 Share Posted April 21, 2009 I recreated this the best I could with given info. Firefox Error Console complains that mBoxCreate() is not defined, (which it isn't because I don't have mbox.js) which tells me it is being called. I also put an alert() at the same spot and it executed. I'd say the problem is in mbox.js. Link to comment https://forums.phpfreaks.com/topic/155076-function-not-executing-inside-iframe/#findComment-815742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.