Forum Moderators: open

Message Too Old, No Replies

onUnLoad, IE & NN

         

prabhunkl

9:31 am on Jul 6, 2002 (gmt 0)

10+ Year Member



I like to submit the current page(in web browser) whenver the page is refreshed by using F5/ Mouse right click.

So,I am calling 'document.form.submit();' on BODY onUnLoad event. It's working fine with NN(4.7,6.0,6.2) and the form is submited successfuly. But it's not working with the IE as per my expectaion.

This is the kind of code i am using inside my HTML page.

<body onUnLoad="document.form.submit();">
<form>
~~~~~~~
~~~~~~~
</form>
</body>

can you Guys let me know what is the reason behind the failure of this Script in IE.

joshie76

1:01 pm on Jul 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi prabhunkl, welcome to WebmasterWorld.

Firstly the syntax looks a little out ... to submit a form the JS syntax is as follows:

document.myFormName.submit();

where,

<form name="myFormName"
. I think thats part of your problem but I also remember reading that certain browsers only allow the calling of the submit() method through a limited number of events like onclick, onchange and so on. It's possible - though I can't remember the exact rules or browsers - that this could also cause you problems.

Anyone offer any clarity on this?

More importantly you should be aware that the onunload event will fire WHENEVER the page is unloaded, not just when they refresh. So if the user types a new URL in the address bar, clicks on a link in your page or closes the browser window the onunload event will fire. Unfortunately there is no way to catch the 'on refresh' event.

rewboss

2:49 pm on Jul 6, 2002 (gmt 0)

10+ Year Member



Why would you want to do this anyway? What you're basically doing is submitting a form without, presumably, the knowledge of the user, which I for one would be very suspicious about.