如何避免“您确定要离开这个页面吗?离开”时提交的修改?在IE的GridView的分页点击 [英] How to avoid the “Are you sure you want to navigate away from this page?” when changes committed? on pagination click of gridview in IE

查看:508
本文介绍了如何避免“您确定要离开这个页面吗?离开”时提交的修改?在IE的GridView的分页点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页包含fields.I想移动到下一个标签之前给予警告用户网格视图与许多输入。我的剧本是工作的罚款在Mozilla Firefox和Chrome,但在IE警报也即将并网观点分页click.I不想上显示在Mozilla分页click.but和Chrome不会发生这种情况。如何避免这一点。

在这里,我给我的剧本

 <脚本>    VAR warnMessage =你必须在此页面上未保存的更改!;    $(文件)。就绪(函数(){
        $('输入:没有(:按钮:提交),文本区域,选择)变化(函数(){。
            window.onbeforeunload =功能(){
                如果(!warnMessage = NULL)返回warnMessage;
            }
        });
        $('输入:提交)点击(函数(五){。
            warnMessage = NULL;
        });
    });< / SCRIPT>

如何避免此消息在GridView的分页单击IE只的?
任何人可以帮助我吗?

感谢


解决方案

刚刚设置的值设置为null分页上点击


  window.onbeforeunload = NULL;


更新1

尝试,而不是你的code这一个:


  VAR myEvent = window.attachEvent || window.addEventListener;
    VAR chkevent = window.attachEvent? 'onbeforeunload':'beforeunload'; ///使IE7,IE8 compitable
    myEvent(chkevent,功能(E){//对于> = IE7,Chrome浏览器,火狐
        VAR confirmationMessage ='你确定要离开页面?'; //空间
        (五|| window.event).returnValue = confirmationMessage;
        返回confirmationMessage;
    });


更新2

您使用后window.onbeforeunload = NULL;在分页控制重新绑定警报在更新面板尝试这种解决方案,它可以帮助你这个问题:


  $(文件)。就绪(函数(){
     bindPageAlert();
   });    功能bindPageAlert()
    {
        VAR myEvent = window.attachEvent || window.addEventListener;
        VAR chkevent = window.attachEvent? 'onbeforeunload':'beforeunload';
        myEvent(chkevent,功能(E){//对于> = IE7,Chrome浏览器,火狐
            VAR confirmationMessage ='你确定要离开页面?'; //空间
            (五|| window.event).returnValue = confirmationMessage;
            返回confirmationMessage;
        });
    }    。Sys.WebForms.PageRequestManager.getInstance()add_endRequest(bindPageAlert);


My web page contains grid-view with many input fields.I want to give alert to user before moving to next tab. My script is working fine in Mozilla Firefox and chrome but in IE the alert is also coming for grid-view pagination click.I don't want to show on pagination click.but in Mozilla and chrome this doesn't happen. How to avoid this .

Here I am giving my script

 <script>

    var warnMessage = "You have unsaved changes on this page!";

    $(document).ready(function () {
        $('input:not(:button,:submit),textarea,select').change(function () {
            window.onbeforeunload = function () {
                if (warnMessage != null) return warnMessage;
            }
        });
        $('input:submit').click(function (e) {
            warnMessage = null;
        });
    });



</script>

How to avoid of this message in gridview pagination click in IE only? Can anybody help me out?

Thanks

解决方案

just set the the value to null on pagination click

   window.onbeforeunload = null;

UPDATE 1

try this one instead of your code:

  var myEvent = window.attachEvent || window.addEventListener;
    var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload'; /// make IE7, IE8 compitable
    myEvent(chkevent, function (e) { // For >=IE7, Chrome, Firefox
        var confirmationMessage = 'Are you sure to leave the page?';  // a space
        (e || window.event).returnValue = confirmationMessage;
        return confirmationMessage;
    });

UPDATE 2

after you use window.onbeforeunload = null; in your pagination control to rebind the alert in your update panel try this solution, it may help you with that issue:

   $(document).ready(function () {
     bindPageAlert();
   });

    function bindPageAlert()
    {
        var myEvent = window.attachEvent || window.addEventListener;
        var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload';
        myEvent(chkevent, function (e) { // For >=IE7, Chrome, Firefox
            var confirmationMessage = 'Are you sure to leave the page?';  // a space
            (e || window.event).returnValue = confirmationMessage;
            return confirmationMessage;
        });
    }

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(bindPageAlert);

这篇关于如何避免“您确定要离开这个页面吗?离开”时提交的修改?在IE的GridView的分页点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆