Jump to content

Recommended Posts

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.