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

Javascript Iframe Refresh Issue with Firefox....

P: 4
Hello,

We are currently running banner ads on a few of our sites and we implemented a javascript so they refresh after every 20 seconds. The script works great in IE though in Firefox it doesn't work at all. We have included the script below and would appreciate any feedback possible.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. var milliSecondsToWait = 20000;
  4.  
  5. function reloadIFrame(){
  6. document.frames['iFrameName'].location.href =
  7. "http://newt1.adultadworld.com/jsc/z5/ff2 .html?n=607;c=2445;s=271;d=14;w=728;h=90;p=271"
  8. myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
  9. }
  10. var myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
  11.  
  12. </script>
The code that we are using in the body of the our pages is:
Expand|Select|Wrap|Line Numbers
  1.                 <td width="729" height="90" valign="top"> <script language="javascript">
  2.           document.write('<iframe id="iFrameName" src="http://newt1.adultadworld.com/jsc/z5/ff2 .html?n=607;c=2445;s=271;d=14;w=728;h=90;p=271" frameborder=0 marginheight=0 marginwidth=0 scrolling="no" allowTransparency="true" width=728 height=90></iframe>');
  3.           </script></td>
Again we appreciate any help in advance and wish we knew more about javascript to not have to bother anyone who is already doing an awesome job helping some many other people.

Have a great day.

Mediagulch
Jun 27 '07 #1
Share this Question
Share on Google+
11 Replies


10K+
P: 13,264
Moved to Javascript forum
Jun 27 '07 #2

acoder
Expert Mod 15k+
P: 16,027
Add name="iFrameName" to the iframe.
Jun 27 '07 #3

ronnil
Expert 100+
P: 134
Add name="iFrameName" to the iframe.
either that or change "frames['iFrameName']" to getElementById('iFrameName')
Jun 27 '07 #4

acoder
Expert Mod 15k+
P: 16,027
either that or change "frames['iFrameName']" to getElementById('iFrameName')
yes, and that too... :)
Jun 27 '07 #5

P: 4
Add name="iFrameName" to the iframe.
Thanks for the feedback on this and when I changed the code to:

Expand|Select|Wrap|Line Numbers
  1. <td width="729" height="90" valign="top"> <script language="javascript">
  2. document.write('<iframe name="iFrameName" id="iFrameName" src="http://newt1.adultadworld.com/jsc/z5/ff2 .html?n=607;c=2445;s=271;d=14; w=728;h=90;p=271" frameborder=0 marginheight=0 marginwidth=0 scrolling="no" allowTransparency="true" width=728 height=90></iframe>');
  3. </script></td>
Firefox still doesn't seem to be refreshing the frame. Did I do this correctly?

Also tried the other version of modifying the javascript to the following:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. var milliSecondsToWait = 20000;
  4.  
  5. function reloadIFrame(){
  6. document.getElementById('iFrameName').location .href="http://newt1.adultadworld.com/jsc/z5/ff2.html? n=607;c=2445;s=271;d=14;w=728;h=90;p=271"
  7. myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
  8. }
  9. var myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
  10.  
  11. </script>
  12.  
This was also unsuccessful for me, I am thinking that I am doing something wrong here.

Any additional feedback would be awesome and thank you again for the help alreay.

MEDIAGULCH
Jun 27 '07 #6

ronnil
Expert 100+
P: 134
do you get any error message from firefox? (go to Tools>Error Console)
Jun 27 '07 #7

P: 4
do you get any error message from firefox? (go to Tools>Error Console)
Hi Ronnil,

Yes I do get an error code from Firefox and it is:

Error: document.getElementById("iFrameName").location has no properties
Source File: file:///c:/dev/web/pages/TMP7q0g9kb8jp.htm
Line: 15

Hope that helps and how can we fix this?
Jun 27 '07 #8

ronnil
Expert 100+
P: 134
try removing the .href so it becomes

document.getElementById('iFrameName').location = 'yoururl';
Jun 27 '07 #9

P: 4
try removing the .href so it becomes

document.getElementById('iFrameName').location = 'yoururl';
Removed the .href and no longer seeing the errors, though the iframe doesn't appear to be freshing. So the code now looks like this:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. var milliSecondsToWait = 20000;
  4.  
  5. function reloadIFrame(){
  6. document.getElementById('iFrameName').location = "http://newt1.adultadworld.com/jsc/z5/ff2 .html?n=607;c=2445;s=271;d=14;w=728;h=90;p=271"
  7. myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
  8. }
  9. var myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
  10.  
  11. </script> 
Any ideas?
Jun 27 '07 #10

acoder
Expert Mod 15k+
P: 16,027
See this link.

Either access as part of the frames array and use location.href or as an object and use the src property.
Jun 28 '07 #11

P: 85
hi
i also seem to have same problem
when i use

document.getElementById("myif").src=my new url

it works fine in IE
but dont do anything in firefox or netscape or opera

i have the iframe hidden and when i load the url in document.getElementById("myif").src i also do document.getElementById("myif").visibility="visibl e"
Aug 9 '07 #12

Post your reply

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