onunload

Problem with jquery ajax and google chrome

早过忘川 提交于 2019-12-10 23:12:29
问题 I'm using jQuery to show a confirmation message for the user when leaving the page as follows: var changes = false; window.onunload =function() { if (changes) { $.post("check.php",{undovideokey:VID}); } else return null; }; on the other hand <input type='submit' name='Add' value='submit ' align='right' onclick="changes = true;" /> A problem occurs when running the code in Google Chrome when I refresh the page. I have seen many problems like this but there is not helpful answers. jQuery ajax

javascript/jquery open.window popup fires onunload after about:blank unloads

你离开我真会死。 提交于 2019-12-10 22:33:37
问题 Let's say I have a button that opens a popup with window.open(): <button id = "my-button">Open window</button>​ And I want to capture when this window closes. I use the following code: $('#my-button').on('click', function() { popup = window.open('http://www.google.com', 'my_popup', "width=800,height=600,scrollbars=no,resizable=yes,status=yes,toolbar=no,location=no,menubar=no"); $(popup.document).ready(function() { console.log('ready!'); $(popup).on('unload', function() { console.log('unloaded

Show popup window when the browser close

烂漫一生 提交于 2019-12-10 17:18:19
问题 I'm developing an eCommerce(PHP) web site and here's my requirement. Once the customer leave the order page or close the browser, I would like to offer another product with pop up or alert box. If they choose 'Yes', it will redirect to another product page instead of closing window. I tried with javascript window.open() on body "onunload" event. But the browsers keep blocking it. Is there anyway to accomplish this? Thank you, Den 回答1: First off: This is not user friendly at all. Just like

Strategies for preserving form data ( on tab/browser close )

血红的双手。 提交于 2019-12-10 15:56:37
问题 I have an issue with a task management application where occasionally users close their browsers/tabs and the information which they type goes away because they accidentally close a browser/tab, resulting in the loss of the text which they've entered ( and some can spend half an hour entering in text ). So I have to provide a solution, I have a couple ideas but wanted input on the best to go with, or if you have a better solution let me hear ya. Option 1: On the window.onunload or possibly

OnUnload message needed for external links

▼魔方 西西 提交于 2019-12-10 02:38:13
问题 I need a message script that will only come up when people are leaving the current webpage and not the current website. When people are leaving the website entirely, the message will come up and they will need to press the OK button to stay at the current page (and cancel to leave the website). The script may not run when people actually stay on the website or when they click on internal links or pages. Can this be done? 回答1: Check out this very basic example solution. It sets the

jQuery ajax call in onunload handler firing AFTER getting the page on a manual refresh. How do I guarantee onunload happens first?

和自甴很熟 提交于 2019-12-09 03:38:56
问题 I have a situation where on page unload I am firing a request to delete the draft of a user's work. This works fine until a user chooses to refresh the page, whereupon inspecting Chrome's network tab shows that Chrome is loading the new page before the ajax request is actually fired. The result is a new draft is created by the page load, and then deleted right away by the ajax call. Here is basically what I'm doing: window.onbeforeunload = function(){ if (pageUpdated){ return 'Are you sure

How to change the text of “Are you sure you want to leave this page?” function script of “onunload”?

血红的双手。 提交于 2019-12-08 13:45:25
问题 How to change the text of this function script?: window.onbeforeunload = function(e) { return 'Are you sure you want to leave this page? You will lose any unsaved data.'; }; i want to translate the text " 'Are you sure you want to leave this page? You will lose any unsaved data.' " so it can say the same but in my language... how to do it? Please help - thanks (when i translate it, it doesnt change in the frontend). Thanks in advance guys! 回答1: unfortunately, changing the message seems to

IFrame on unload refresh parent page

元气小坏坏 提交于 2019-12-08 07:02:20
问题 I have an iframe in a page. When the iframe is closed I would like to refresh the parent page. Checking out the iframe element w3 page I see there are no standard events. I considered a polling approach, having the parent page constantly check if the frame is created, and then checking if it is removed and then refreshing, however this approach isn't great. I can imagine sometimes delays between iframe close and page reload if the polling is to infrequent. With a more frequent polling the

Don't have time to send get request on window unload

僤鯓⒐⒋嵵緔 提交于 2019-12-08 03:49:07
问题 I want to notify the server on user closes browser window. I tried all of the $(window).bind("beforeunload", function() { $.get("${contextPath}/notify?direction=logout"); }); and $(window).unload( function() { $.get("${contextPath}/notify?direction=logout"); }); and $(window).unload(function() { $.ajax({ url: "${contextPath}/notify?direction=logout" }); }); but neither work well, despite the fact, that it is said in manual that it probably should. In Firefox I have no notifications only on

user-unfriendly onbeforeunload / onunload

倾然丶 夕夏残阳落幕 提交于 2019-12-06 22:56:27
I'm struggling with onbeforeunload, onunload and generating the right messages at the right time. Any idea welcome. This is the situation: when I use onbeforeunload, the user gets a message to choose whether to navigate away, but I can't turn it off - the message is standard and appears regardless what's in the event handler. when I use onunload, I can control the "bye" messages that occur, but I cant offer the user the opportunity to change their mind. So for example, if there is data to save. With onbeforeunload, a message pops up, -regardless of the state of the user's data- asking if they