![]() |
How can I submit a form depending on some vars?
Hi, I'm trying to submit a form depending on the result of a var, and specifically it is a window confirmation to save the form if the user is leaving the page. This is the code I tried:
Code:
|
And WHERE are you calling that code FROM?
If it is from window.onbeforeunload it will never work. And quite frankly, window.onbeforeunload is the only reliable place to put a "now leaving the page" trap. But the most you can do there is allow the user to cancel his request to leave the page. (I have wondered if you could make a synchronous HTTP request at that point. I think you could, but that's beginning to get pretty complex.) |
Yes, I am trying to call if from a window.unbeforeunload... what do you mean with a "synchronous HTTP request"?
|
Synchronous AJAX. Or better named SJAX, I suppose.
Code:
var http = new XMLHttpRequest(); |
Quote:
Calls to alert() confirm() and prompt() should only ever be used for debugging, they should never be used in a live web page. |
All true, Felgall, but irrelevant. You can't use confirm() in onbeforeunload anyway.
|
| All times are GMT +1. The time now is 02:53 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.