I'm fairly new to javascript and was hoping i could have a little help...
I have a page containing a form and an iframe. The iframe is initially empty (src="about:blank"). The target of the form is the iframe, so when the form is submitted the iframe loads a page (which is remote and I cannot edit). What i would like to happen is that when the contents of the iframe has finished loading, the page (as in: the entire page) then redirects to another page.
Below is a simplified example of the kind of thing i've been trying, but not been able to make work:
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <script language="Javascript">
- function func() {
- document.getElementById("ifrm").onload = re();
- }
- function re() {
- document.location.href = "nextpage.php";
- }
- </script>
- </head>
- <body>
- <form action="somepage.php" target="ifrm">
- etc etc
- <input type="submit" onClick="func();">
- </form>
- <iframe id="ifrm" name="ifrm" src="about:blank"></iframe>
- </body>
- </html>
It is very important that the solution is cross-browser compatible and i believe (although i may be wrong) that Safari does not support 'onload' events for iframes. If so, is there a work-around?
Thanks for your time,
Chris