請寫一段Javascript的代碼防止用戶提交表單後刷新網頁(例如按F或按IE上的刷新按鈕)重新提交表單內容頁面提交是在本頁面提交到本頁面大家幫幫忙?
下面的代碼只是實現了屏蔽鼠標右鍵Ctrl+nshift+FF刷新退格鍵
function KeyDown(){
//屏蔽鼠標右鍵Ctrl+nshift+FF刷新退格鍵
//alert(ASCII代碼是+eventkeyCode);
if ((windoweventaltKey)&&
((windoweventkeyCode==)|| //屏蔽 Alt+ 方向鍵 ←
(windoweventkeyCode==))){ //屏蔽 Alt+ 方向鍵 →
alert(不准你使用ALT+方向鍵前進或後退網頁!);
eventreturnValue=false;
}
if ((eventkeyCode==) || //屏蔽退格刪除鍵
(eventkeyCode==)|| //屏蔽 F 刷新鍵
(eventkeyCode==)|| //屏蔽 F 刷新鍵
(eventctrlKey && eventkeyCode==)){ //Ctrl + R
eventkeyCode=;
eventreturnValue=false;
}
if ((eventctrlKey)&&(eventkeyCode==)) //屏蔽 Ctrl+n
eventreturnValue=false;
if ((eventshiftKey)&&(eventkeyCode==)) //屏蔽 shift+F
eventreturnValue=false;
if (windoweventsrcElementtagName == A && windoweventshiftKey)
windoweventreturnValue = false; //屏蔽 shift 加鼠標左鍵新開一網頁
if ((windoweventaltKey)&&(windoweventkeyCode==)){ //屏蔽Alt+F
windowshowModelessDialog(about:blankdialogWidth:px;dialogheight:px);
return false;}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19708.html