469,925 Members | 1,520 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

refreshing the window or iframe without click sound

258 100+
Here you can see the script I found in google to refresh a page without hearing any click sound which is usual to hear when a link is clicked or a page is refreshed.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <script type="text/javascript" >
  3. window.onload = doLoad;
  4.  
  5. function doLoad()
  6. {
  7. setTimeout( "refresh()", 5*1000 );
  8. }
  9.  
  10. function refresh()
  11. {
  12. window.location.reload( false );
  13. }
  14. </script>
  15.  
  16.  
I have a PHP page which needs to refresh every 5 seconds. Actualy this JAVA script works fine without any problem

BUT
the problem i'm thinking about is that if the server does not respond (just once) as it happends sometimes the page will not be loaded again and if the page is not loaded it will not get refreshed anymore...

SO
I was thinking to put an IFRAME inside the main page and refresh it from the main page.. So even if server doesn't respond once, page will not stop refreshing and it may take another 5 seconds to refresh

This script refreshes the current window but unfortunately i dont know anything about JAVA and the only thing i do is to copy and past this script inside my page between HEAD tags... I'll be thankful if anyone help me refresh an IFRAME with this script ( whitout any click sound )
Sep 20 '07 #1
6 4930
acoder
16,027 Expert Mod 8TB
Try:
Expand|Select|Wrap|Line Numbers
  1. document.frames['iFrameName'].location.reload();
Sep 20 '07 #2
acoder
16,027 Expert Mod 8TB
Added "or iframe" to the thread title.
Sep 20 '07 #3
bnashenas1984
258 100+
Thanks for the help
But the script is not working with Mozilla. The old one worked with both Mozilla and IE but this one is only working in IE

Here is the new one

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.  
  5. <script type="text/javascript" >
  6. document.frames['myframe'].onLoad = doLoad();
  7.  
  8. function doLoad()
  9. {
  10. setTimeout( "refresh()", 1*1000 );
  11. }
  12.  
  13. function refresh()
  14. {
  15. document.frames['myframe'].location.reload( false );
  16. }
  17. </script>
  18.  
  19. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  20. <title>Untitled Document</title>
  21. </head>
  22.  
  23. <body>
  24. <iframe name="myframe" id="myframe" frameborder="0" src="1.php" width="100" height="100" onload="doLoad();"></iframe><br />
  25. </body>
  26.  
  27. </html>
  28.  
  29.  
Sep 20 '07 #4
acoder
16,027 Expert Mod 8TB
OK, that should be window.frames[] or just frames[].

onLoad should be onload.

You should get an error on the line which tries to access the iframe before it has appeared. Put that statement into body/window onload.
Sep 20 '07 #5
bnashenas1984
258 100+
As you said I changed window.frames['myframe'] to frames['myframe'] and its working now ( both with IE and Mozilla )

Thank youuuuuuuuuu

That was a big help. I wish some day i'll be an expert like you guys and help others..
Sep 20 '07 #6
acoder
16,027 Expert Mod 8TB
You're welcome.

Keep trying. Everyone's learning all the time no matter how much of an expert they are.
Sep 21 '07 #7

Post your reply

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

Similar topics

1 post views Thread by Jennyfer J Barco | last post: by
18 posts views Thread by len.hartley | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.