By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,931 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,931 IT Pros & Developers. It's quick & easy.

Error in Firefox loading HTML page into iFrame

P: 2
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
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
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

P: 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
Expert Mod 15k+
P: 16,027
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
Expert Mod 15k+
P: 16,027
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.