kansun
asked on
Prevent a visitor from navigating away from curent page
Hello and good day,
I have a web page with a html form in it.
The form has some mandatory fields too with submit button.
Now this is what i wanna achieve...
If a visitor arrives on this form page and tries to leave the page without submitting the form (either by typing a new url in address bar or by clicking back button) then the visitor should be prevented from navigating away from the form by displaying a small css html window (NOT the typical Javascript alert) with a message asking if visitor needs any assistance with a text area and 2 buttons (Yes button and Navigate away button). If he presses yes button then all that he types in the textarea will be submitted to website admin and if he wishes to navigate away from page he can by clicking on Navigate away button.
Can this be done?
If yes can you please upload a complete working code (a basic code at least)
Thanks
kansun
I have a web page with a html form in it.
The form has some mandatory fields too with submit button.
Now this is what i wanna achieve...
If a visitor arrives on this form page and tries to leave the page without submitting the form (either by typing a new url in address bar or by clicking back button) then the visitor should be prevented from navigating away from the form by displaying a small css html window (NOT the typical Javascript alert) with a message asking if visitor needs any assistance with a text area and 2 buttons (Yes button and Navigate away button). If he presses yes button then all that he types in the textarea will be submitted to website admin and if he wishes to navigate away from page he can by clicking on Navigate away button.
Can this be done?
If yes can you please upload a complete working code (a basic code at least)
Thanks
kansun
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
additionaly onbeforeunload don't work on all browsers.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's the worst user experience you can provide!!
Do the best you can to attract visitors, but don't try to prevent them from navigating away!
Do the best you can to attract visitors, but don't try to prevent them from navigating away!
You cannot force the user to do anything. If you make it difficult to leave, my guess is they will not be back.
ASKER
Hi My friends,
I expected a solution. But i just got few advices here.
:-)) Can anyone provide a soln for this.... thx
I expected a solution. But i just got few advices here.
:-)) Can anyone provide a soln for this.... thx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And onbeforeunload may not be supported in all browsers.
ASKER
I've requested that this question be deleted for the following reason:
no answers
no answers
The answer is, "You cannot prevent the user from leaving."
What more do you want?
What more do you want?
99% of time for this question the member want a << solution >> not a << right answer >>...
<waiting_for_the_envelope>
...and the solution is...
</waiting_for_the_envelope >
...and the solution is...
</waiting_for_the_envelope
ASKER
thank you
There are no US-legal solutions to your question, unless you control the machine from which the user is browsing (like a kiosk machine). I presumed from your question, however, that this was not the case.
>>unless you control the machine from which the user is browsing (like a kiosk machine)
So, what is the "solution" in that case?
So, what is the "solution" in that case?
small css html window (NOT the typical Javascript alert)