FAQ Database Discussion Community


Trouble with a common-class object listener in Javascript?

javascript,events,event-handling,onbeforeunload
I have the following Javascript: function save_data_check(e) { var input_value = $('.input-right').text(); if (input_value !== "") { if(!e) e = window.event; e.cancelBubble = true; e.returnValue = 'You have unsaved data on this page.'; if (e.stopPropagation) { e.stopPropagation(); e.preventDefault(); } } } window.onbeforeunload = save_data_check; The intended function of this code...

prevent onbeforeunload to close page in any case

javascript,jquery,onbeforeunload
I want to prevent browser to close page in any case or in other case, Prevent browser to do anything when onbeforeunload is called. Here is my code which i have tried. (function() { var proxied = window.onbeforeunload; window.onbeforeunload = function(e) { e.preventDefault(); e.stopPropagation(); //i want to stop everything console.log('stay...

Detect browser close event

javascript,browser,cross-browser,onbeforeunload
I want to capture the browser window/tab close event. I have tried the following But not working: <script type="text/javascript"> window.onbeforeunload = function(){ myUnloadEvent(); } function myUnloadEvent() { alert ('Calling some alert messages here'); } </script> <body> Body of the page goes here. </body> Tried these links also but no more...

.NET MVC 4 website javascript function in popup window wouldn't run

javascript,jquery,asp.net-mvc-4,popup,onbeforeunload
I am working on questionnaire that is being asked when user lands on the page, if he agrees to do it popup window (action is on different Controller) is opened (works fine) an when main window is closed it should signal to popup to start questionnaire. However following mechanism does...

SignalR connection disconnects upon OnBeforeUnload

signalr,onbeforeunload
I'm having C# self hosted server application using SignalR. My client is SPA (angualr,javascript HTML5). My application have some termination process which should run when leaving the page (running when OnBeforeUnload occurs and the user asks to leave...). The termination process contains some server calls. Till today I worked with...

Perform some event when php session timeout

php,codeigniter,session,timeout,onbeforeunload
I tried it with jquery 'onbeforeunload',but failed as jquery doing that action even on refreshing page. All i want to do is ,perform a db function just before any user close his browser or computer.So that i can know he has logged out.I want to add facebook like functionality "Logged...

AngularJS custom window while changing page

javascript,angularjs,onbeforeunload
I want to do a custom modal asking if user wants to save changes before leaving a page, using ui.bootstrap. I'm not using angular route configuration (so i guess i can't use '$locationChangeStart'or '$routeChangeStart'). I can't use window.onbeforeunload as you can't custom the popup window ( apart maybe from the...