468,103 Members | 1,170 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

Error in Firefox loading HTML page into iFrame

Hi All!
I'm hoping someone can help me with this situation. I am a developer working on a project that has a video voting page.
The situation is this:
The parent page has an iFrame ( named iFrame1 ) and it is supposed to load in an external .html page that has a flash video in it. The external .html page is supposed to load when a user clicks on a thumbnail image on the parent page. There are 20 external .html pages that a user can load in by clicking on the associated thumbnail on the parent page. I am using JavaScript to tell it to load the next .html page because the parent page has .asp code in it for a voting mechanism.
The code for the thumbnail is:

[HTML]<div align="left">
<a href="javascript:loadVid('video1.html')"><img src="assets/VC01t.jpg" width="97" height="55" border="0" onClick="hidLastVideoPlayed.value='video1.html'"/></a>
[/HTML]
The JavaScript code in the external file ( iFramevid.js ) is:

Expand|Select|Wrap|Line Numbers
  1. function loadVid(iFrameURL)
  2. {
  3.     iFrame1.location.href = iFrameURL;
  4.  
  5. }
  6.  
This all works great in Internet Explorer but when I try it in Firefox I get an error:
"iFrame1 is not defined" and it shows the line 'iFrame1.location.href = iFrameURL;'
It doesn't load the .html document in the iFrame. I just get the error.
I also get another error:

hidLastVideoPlayed is not defined
loadVid("video3.html")

Does anyone know how to get around this or fix it? I'm perplexed. It would be one thing if it didn't work in IE.
Thanks in advance!

djlender
Jan 17 '08 #1
4 3988
acoder
16,027 Expert Mod 8TB
You have to access the iframe properly using document.frames["iFrame1"]. IE allows you to access by name/id globally, but that's incorrect.
Jan 18 '08 #2
You have to access the iframe properly using document.frames["iFrame1"]. IE allows you to access by name/id globally, but that's incorrect.
You are quite correct. I just figured that out with the help of a couple fellow co-workers. The new code that seems to work is:
<a href="video20.html" target="iFrame"><img src="assets/VC20t.jpg" width="97" height="55" border="0" /></a>
Jan 18 '08 #3
acoder
16,027 Expert Mod 8TB
You are quite correct. I just figured that out with the help of a couple fellow co-workers. The new code that seems to work is:
<a href="video20.html" target="iFrame"><img src="assets/VC20t.jpg" width="97" height="55" border="0" /></a>
Yes, that should work because you're targetting the iframe by name.
Jan 18 '08 #4
acoder
16,027 Expert Mod 8TB
You have to access the iframe properly using document.frames["iFrame1"]. IE allows you to access by name/id globally, but that's incorrect.
Just noticed the document.frames. That should, of course, be window.frames[].
Jan 18 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Jim Marquardson | last post: by
7 posts views Thread by WH | last post: by
12 posts views Thread by wangzx | last post: by
7 posts views Thread by John Kotuby | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.