score:0
on behalf of @denys séguert :
The short answer is that you can't.
The onbeforeunload event was initially introduced by Microsoft to allow a standard confirmation dialog. It is now supported in the original form by most browsers and in most case a short, non interactive, function is allowed to execute (for example you may log your state in the localStorage). But, as described in the cross-browser jQuery API, this is unreliable :
The exact handling of the unload event has varied from version to version of browsers. For example, some versions of Firefox trigger the event when a link is followed, but not when the window is closed. In practical usage, behavior should be tested on all supported browsers, and contrasted with the proprietary beforeunload event.
As there are many potential security problems related to the execution of a task when the user asked to end the page (and thus the script), this will probably be unreliable until (and if) a serious normalization effort is done to precise what exactly can be done in a onbeforeunload callback.
For the predictable future, it's recommended to not depend on onbeforeunload but to use other schemes, for example constant background saving or a big "save" button.
Related Query
- jQuery Mobile popup won't show after page navigation, only shows after hard refresh, or returning to same page
- Show a popup on page load and then show and hide it at regular time intervals
- Navigation menu to show current page link active - jquery
- How do i render and show another page when user hovers over the link?
- Show div on page load - Counteracting toggle function
- How to show a div on top of the page in fixed position?
- jquery show hide the requested page
- How to show Div after a Specific time of page load?
- Is it correct that page elements created by jQuery do not show up in the source code
- Im trying to hide an element when the page opens and then show when a button is clicked
- how to silently guarantee executing an ASP.NET MVC3 action on page unload
- Show N rows per page in HTML table
- How to show Realtime/Streaming Graph on Jsp page
- Show the Content of input when page loads
- ajax popup load from another page
- Simple jQuery Modal Window not showing popup on page load
- Need Header row to show when scolling down page
- Execute jQuery Popup When Page Loads?
- Page jerks and goes to the top after I show an id element
- show the selected value in dropdown on edit jsp page on page load (Spring MVC)
- How can I create popup window by jquery to external page and get a value from it to the parent page when I click a button there?
- how to get images from other web page and show in my website
- how to redirect a page which creates a popup, from that created popup using jQuery?
- Get the selected values from a list and show it in a new page
- How to show loading gif while page hasn't fully loaded
- Hide/ Show div based on URL that loads without page reload
- How to use jquery to show an element after JSON data is sent back to page
- Want to show and hide data using jquery or javascript inside html page
- How to show a jquery mobile popup at the bottom of the page?
- jQuery FullCalendar onclick show popup
- Refresh parent page before popup page closed
- How to show notifications in a JSP page in real time
- Show checkbox selections on a summary page
- google chrome extension- popup page not showing correctly
- CSS to display a popup at 20px from top on a scrollable page
- How to show popup window on validation event?
- Show FB status update popup on click?
- How to open a html page as popup within another html page
- On page load show option from select form
- Opening show page in a modal with updating url in address bar as in instagram example using Ruby on Rails 5
- AutoComplete result show in left top of page instead bottom of input in spring mvc
- can not show javascript popup table in ASP.net
- How to show a page by default on page load
- How to communicate between popup page and background page and store the info that I already get?
- Make a partial show up without refreshing the page
- Change HTML Page in Crossrider Popup
- Load magnific popup on page load
- How to show D3 chart using Bootstrap modal popup when click on button and download it as image format
- How do i show a simple loading message on the screen while my page fetches data from server?
- Show div of different page when hovering on element in index page
More Query from same tag
- multiple jquery datepicker
- Show modal on load only once
- Colorbox - How to display only a specific DIV
- Show/Hide DIV by Multiple Checkboxes
- JsRender and accessing nested objects
- Check for misspelt words using PHP
- Weird CTRL key detection in Firefox
- Fill divs with strings from array
- Ajax. On Ajax success call same ajax function one more time
- How can i get a checkbox text inside a <li> tag and show this in another label in jQuery?
- Problems calling fullcalendar method
- How to read an HTML table like a battleship game?
- jQuery: Search for div containing specific mark up
- Javascript passing var on click in a table
- jquery validation: How to figure out the form associated with a validator?
- MYSQL Data -> PHP arrays -> Javascript (or Jquery) How can I pass the data with JSON?
- Material Design Lite and jQuery, something is wrong with smooth scroll
- Attach Click event to div to get inner div value
- How to pass additional parameters to ajax call back function?
- How to change class of elements in adjacent rows of HTML table using jQuery's nextAll() selector
- Get values of tds in a table
- how can i get checkbox name when checked without submit button
- jQuery Dropdown Menu Under IE7
- Issue with calling a prototype function with setInterval
- Tabular Data With Paging and Sorting
- Check for first or last sibling with class in table row (jQuery)
- Keeping track of open windows
- How can I pass html from textarea into jQuery?
- how to auto fill value with jquery from json object
- Replace the value of a key in a jquery object