刷新、关闭等误操作造成当前页面信息的丢失的解决方案

有时候在编辑页面用户做修改后,可能会有刷新、关闭等误操作造成当前页面信息的丢失,
何不先提醒一下用户呢?
代码
<% @ Page Language = " C# "  AutoEventWireup = " true "  CodeBehind = " ProductEdit.aspx.cs "  Inherits = " Web.Admin.Product.ProductEdit "   %>
<! DOCTYPE html PUBLIC  " -//W3C//DTD XHTML 1.0 Transitional//EN "   " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head runat = " server " >
    
< title > 产品修改 </ title >
    
< link href = " ../images/Guide.css "  type = " text/css "  rel = " stylesheet "   />
    
< link href = " ../images/index.css "  type = " text/css "  rel = " stylesheet "   />
    
< link href = " ../images/MasterPage.css "  type = " text/css "  rel = " stylesheet "   />
    
< link href = " ../images/xtree.css "  type = " text/css "  rel = " stylesheet "   />

    
< script language = " javascript "  type = " text/javascript " >
        var pb_strConfirmCloseMessage;
        var pb_blnCloseWindow 
=   false ;
        pb_strConfirmCloseMessage 
=   " 您真的要离开本页吗? " ;
        function ConfirmClose() {
            window.
event .returnValue  =  pb_strConfirmCloseMessage;
            pb_blnCloseWindow 
=   true ;
        }
        function ShowConfirmClose(blnValue) {
            
if  (blnValue) {
                document.body.onbeforeunload 
=  ConfirmClose;
            } 
else  {
                document.body.onbeforeunload 
=   null ;
            }
        }
    
</ script >

</ head >
< body onload = " ShowConfirmClose(true); " >
    
< form id = " form1 "  runat = " server " >
</ form >
</ body >
</ html >

 

你可能感兴趣的:(解决方案)