Is it possible to somehow bring up a question with a request to evaluate the quality of the site on a scale from 1 to 10, when the user closes the tab in the browser, and if the rating is below 9 ask what, in his opinion, is the problem?
This should be like an example window when asked to confirm whether you really intend to leave the page. Either the output window formed using CSS .
|
2 answers
And if you try using window.onbeforeunload ??
Something like this:
<script> window.onbeforeunload = function (e) { e = e || window.event; // For IE and Firefox prior to version 4 if (e) { e.returnValue = 'Sure?'; } // For Safari return 'Sure?'; }; </script> I copied it from here: https://stackoverflow.com/questions/10311341/confirmation-before-closing-of-tab-browser You should probably use e.preventDefault () here ...
- The principle of work that is necessary, but is it possible to put a vote there? those.
htmlandcsscode - Plush - Add in event handler generation and form creation with voting. By ajax'u send the answer to the server. Then close the tab (using window.close () it seems ...) - Michael Vaysman
onbeforeunloadcannot prevent the window from closing, so form creation will fail - Grundy- @Grundy Yeah .... you're right ... :( - Michael Vaysman
- Help for this event - Grundy
|
I think it should work.
In the snippet form submission is blocked by the browser protection, but on the page should not.
window.onbeforeunload = function () { $("body").html($("#rate").show().submit(function () { setTimeout(function () { window.close() }) })); window.onbeforeunload = null; return "Пожалуйста, останьтесь на странице и оцените её.\nПосле оценки вкладка сама закроется." }; input { vertical-align: middle; } #rate { display: none; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> Тут был какой-то контент. <form id=rate> <input type=range min=0 max=10 value=0> <input type=submit value=Отправить> </form> To see the dialogue, you need to run the snippet again.
- Yes, this is an option. Can I add my text to the dialog box "This page asks you to confirm ..."? - Plush
|