如何确定事件的触发因素(关闭浏览器、关闭选项卡、在其他页面上重定向等)?
function winUnload(){
var pathToCloseCurrentTab = window.location.protocol + "//" + window.location.host + '<%= ResolveUrl("~/Services/SenderAjax.asmx") %>' + "/CloseCurrentTab";
$.ajax({
type: 'POST',
url: pathToCloseCurrentTab,
dataType: 'JSON',
data: {'data': $('input[id$=hfTimeLoadLayOut]').val()}
});
}
window.onbeforeunload= function (evt){
winUnload();
};