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

iFrame onLoad Problem

P: 3

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
  1. <html>
  3. <head>
  4. <script language="Javascript">
  6. function func() {
  7.     document.getElementById("ifrm").onload = re();
  8. }
  9. function re() {
  10.     document.location.href = "nextpage.php";
  11. }
  13. </script>
  14. </head>
  16. <body>
  18. <form action="somepage.php" target="ifrm">
  19.     etc etc
  20. <input type="submit" onClick="func();">
  21. </form>
  23. <iframe id="ifrm" name="ifrm" src="about:blank"></iframe>
  25. </body>
  26. </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,

Sep 13 '07 #1
Share this Question
Share on Google+
3 Replies

P: 3
Still really struggling with this, even the smallest amount of help would be much appreciated!

There must be a genius here who can give me some help!
Sep 13 '07 #2

Expert 100+
P: 1,351
iframes do not have an onload event, they use the onload of page its loading.
Sep 13 '07 #3

P: 3
So is what i am doing not possible given that the iframe page is remote and i am not able to edit it?
Sep 13 '07 #4

Post your reply

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