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

submit form when user leaves browser mozila

P: 1
Dear sir
i want to submit a form when user leaves mozila browser.
My Code is as follows

test1.jsp

[HTML]<script language="javascript">
function submitthis()
{

document.form1.method='post';
document.form1.action='test.jsp';
document.form1.submit();

}
</script>
</head>
<body onBeforeUnload="submitthis()">
<form name="form1">
<input type="hidden" name="hidden" value="12"/>
</form>
</body>
</html>[/HTML]

this works in ie fine. but not working in mozila.
will u pls provide me proper solution.

thanks
Jan 10 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

Is this a good idea anyway? If the user chooses to leave and you submit the form, it will go to the action page - totally unexpected behaviour!

onbeforeunload is non-standard, but support has been added in Firefox and one or two other browsers. However, it should be used with caution. When significant changes have been made which could be lost, a reminder before the user closes or navigates away from the page would be useful.

I don't think you can submit a form when a user leaves a page, but you can pop up a warning if you want.
Jan 11 '08 #2

Post your reply

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