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

refreshing the window or iframe without click sound

P: 258
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
  2. <script type="text/javascript" >
  3. window.onload = doLoad;
  5. function doLoad()
  6. {
  7. setTimeout( "refresh()", 5*1000 );
  8. }
  10. function refresh()
  11. {
  12. window.location.reload( false );
  13. }
  14. </script>
I have a PHP page which needs to refresh every 5 seconds. Actualy this JAVA script works fine without any problem

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...

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
Share this Question
Share on Google+
6 Replies

Expert Mod 15k+
P: 16,027
Expand|Select|Wrap|Line Numbers
  1. document.frames['iFrameName'].location.reload();
Sep 20 '07 #2

Expert Mod 15k+
P: 16,027
Added "or iframe" to the thread title.
Sep 20 '07 #3

P: 258
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" "">
  2. <html xmlns="">
  3. <head>
  5. <script type="text/javascript" >
  6. document.frames['myframe'].onLoad = doLoad();
  8. function doLoad()
  9. {
  10. setTimeout( "refresh()", 1*1000 );
  11. }
  13. function refresh()
  14. {
  15. document.frames['myframe'].location.reload( false );
  16. }
  17. </script>
  19. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  20. <title>Untitled Document</title>
  21. </head>
  23. <body>
  24. <iframe name="myframe" id="myframe" frameborder="0" src="1.php" width="100" height="100" onload="doLoad();"></iframe><br />
  25. </body>
  27. </html>
Sep 20 '07 #4

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

P: 258
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

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