Iframe reload with setTimeout

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Sep 2008
Posts: 4
Reputation: Dalli is an unknown quantity at this point 
Solved Threads: 0
Dalli Dalli is offline Offline
Newbie Poster

Iframe reload with setTimeout

 
0
  #1
Sep 14th, 2008
Hello,
I have a problem with something very simple, but because of my 0 knowledge in js, i can't understand what am i doing/thinking wrong. I have one main site, that have 2 small iframes in between everything else. In the second iframe i have a form, when i submit the form, i need the first iframe to be reloaded with delay so it can read the updated info from database.
So, in the second (with the form) iframe i have the code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <head><script type="text/javascript">
  2. function f() {
  3. parent.mini.location.reload();
  4. }
  5. function r() {setTimeout(f(),2000);
  6. }
  7. </script>
  8. </head>
and on the submit button on the form i have onclick="r()"
This reloads the mini iframe right away and gives Useless setTimeout call (missing quotes around argument?) in FF error console. I tried having some simple examples of setTimeout function, but still didn't get it to work. Tried also with every single syntax i could find online, with no result. Does anybody have any suggestions on what i should/could do?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Iframe reload with setTimeout

 
0
  #2
Sep 15th, 2008
This is why, you keep on getting those error-->

function r() { setTimeout(f(),2000); }
You forgot to quote it.
setTimeout("f()", 2000)

And here's my quick example about reloading those iframes' on your page! Hope it helps you... Good day..

  1. <html>
  2. <head>
  3. <title><!--Sample--></title>
  1. <script type="text/javascript">
  2. function f()
  3. {
  4.  
  5. var refresh = document.getElementById('frame1');
  6. /* You can also use -->
  7.   refresh.contentWindow.location.reload( true );
  8.   but not all browser support this function!
  9.   So i wil just perform a simple trick to get things done... Enjoy
  10.   Code is as follows:
  11.  */
  12. timer = setTimeout('f()', 1000);
  13. if ( timer == 5 ) { clearTimeout( timer );
  14. refresh.src = 'yourpage.html#'; //or you can just set this = refresh.src
  15.  
  16. }
  17. }
  18. </script>
  1. </head>
  2. <body>
  3.  
  4. <div>
  5. <iframe id="frame1" src="yourpage.html"></iframe></div><br />
  6. <input type="button" value="click" onclick="f()" />
  7. </body></html>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC