1.11M Members

Iframe reload with setTimeout

 
0
 

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:

<head><script type="text/javascript">
function f() {
  parent.mini.location.reload();
}
function r() {setTimeout(f(),2000);
}
</script>
</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?

 
0
 

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

<html>
<head>
<title><!--Sample--></title>
<script type="text/javascript">
function f()
{ 
    
var refresh = document.getElementById('frame1');
/* You can also use -->
   refresh.contentWindow.location.reload( true );
   but not all browser support this function!
   So i wil just perform a simple trick to get things done... Enjoy
   Code is as follows:
 */
  timer = setTimeout('f()', 1000);
if ( timer == 5 ) { clearTimeout( timer ); 
refresh.src = 'yourpage.html#'; //or you can just set this = refresh.src
 
} 
}
</script>
</head>
<body>

<div>
<iframe id="frame1" src="yourpage.html"></iframe></div><br />
<input type="button" value="click" onclick="f()" />
</body></html>
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article