頁面關閉和刷新onbeforeunload事件的正確用法

<body οnbefοreunlοad="runOnBeforeUnload()">


 

var g_blnCheckUnload = true;
function runOnBeforeUnload() {
    if (g_blnCheckUnload) {
        try{
            //window.event.returnValue = 'You will lose any unsaved content'; //界面提示框
        	//var url = path+"/realTimePass!closeWindow.action";   //正確的調用方法
        	var url = path+"/realTimePass!jqueryTest.action";   //測試方法
        	$.ajax({
        		url : url,
        		type : 'POST',
        		dataType : 'json',
        		data :  {			
        			crossingId : crossingId
        		},
        		cache : true,
        		timeout :BMS_TIMEOUT,
        		context : this,
        		error : function(jqXHR, textStatus, errorThrown) {
        			bms.util.errorHandler(jqXHR);
        		},
        		success : function(obj){	
        		    
        		}
        	});
        }catch(e){}
    } 
}


 

參考鏈接:

http://www.cnblogs.com/zfc2201/archive/2012/06/22/2558471.html

http://blog.csdn.net/changlich/article/details/1043740

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章