Link to home
Start Free TrialLog in
Avatar of kansun
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
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@WalkaboutTigger :

small css html window (NOT the typical Javascript alert)
additionaly onbeforeunload don't work on all browsers.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!
You cannot force the user to do anything. If you make it difficult to leave, my guess is they will not be back.
Avatar of kansun
kansun

ASKER

Hi My friends,
I expected a solution. But i just got few advices here.
:-)) Can anyone provide a soln for this.... thx
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And onbeforeunload may not be supported in all browsers.
Avatar of kansun

ASKER

I've requested that this question be deleted for the following reason:

no answers
The answer is, "You cannot prevent the user from leaving."

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>
Avatar of kansun

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?