Connecting Tech Pros Worldwide Forums | Help | Site Map

Javascript Iframe Refresh Issue with Firefox....

Newbie
 
Join Date: Jun 2007
Posts: 4
#1: Jun 27 '07
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

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


Moved to Javascript forum
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


Add name="iFrameName" to the iframe.
ronnil's Avatar
Expert
 
Join Date: Jun 2007
Posts: 132
#4: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


Quote:

Originally Posted by acoder

Add name="iFrameName" to the iframe.

either that or change "frames['iFrameName']" to getElementById('iFrameName')
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


Quote:

Originally Posted by ronnil

either that or change "frames['iFrameName']" to getElementById('iFrameName')

yes, and that too... :)
Newbie
 
Join Date: Jun 2007
Posts: 4
#6: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


Quote:

Originally Posted by acoder

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
ronnil's Avatar
Expert
 
Join Date: Jun 2007
Posts: 132
#7: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


do you get any error message from firefox? (go to Tools>Error Console)
Newbie
 
Join Date: Jun 2007
Posts: 4
#8: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


Quote:

Originally Posted by ronnil

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?
ronnil's Avatar
Expert
 
Join Date: Jun 2007
Posts: 132
#9: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


try removing the .href so it becomes

document.getElementById('iFrameName').location = 'yoururl';
Newbie
 
Join Date: Jun 2007
Posts: 4
#10: Jun 27 '07

re: Javascript Iframe Refresh Issue with Firefox....


Quote:

Originally Posted by ronnil

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?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#11: Jun 28 '07

re: Javascript Iframe Refresh Issue with Firefox....


See this link.

Either access as part of the frames array and use location.href or as an object and use the src property.
Member
 
Join Date: Jul 2007
Posts: 85
#12: Aug 9 '07

re: Javascript Iframe Refresh Issue with Firefox....


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"
Reply


Similar JavaScript / Ajax / DHTML bytes