I have written this code
function winUnload() {
alert("Unload Window");
MyMethod();
}
window.onunload = function() { winUnload(); }
This code is working fine in IE and Firefox. But this code is not working in Chrome. Both the statements alert("Unload Window"); and MyMethod(); are not working.
Please try
window.onbeforeunloadinstead forwindow.onunloadfor chrome. You can also try callingonbeforeunloadfrom thebody>tag which might work in chrome.However, we do have a problem with unload function in chrome browser. please check
location.href does not work in chrome when called through the body/window unload event