当我离开页面并浏览新页面时显示确认消息 [英] show confirm message when I leave the page and navigate new page

查看:81
本文介绍了当我离开页面并浏览新页面时显示确认消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的应用程序中有一个母版页面的菜单。如果用户正在使用页面并导航到其他屏幕/页面而未保存,则应用程序会要求确认。它应该显示确认消息,例如你想离开这个页面而不保存吗?。有没有可能做什么?

Hi,

In my application have a menu in master page. The application ask for confirmation if the user is working on a Page and navigates to other screen/page without saving. It should show confirm msg like 'Do you want to leave this page without saving?'. Is there any possiblities to do?

推荐答案

试试这个: -

try this:-
<script type="text/javascript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    return "Do you want to leave this page without saving?";
  }
</script>


使用此

------------







Use this
------------



<script type="text/javascript" language="javascript">
               window.onbeforeunload = function() {
                   var Ans = confirm("Are you sure you want change page!");
                   if(Ans==true)
                       return true;
                   else
                       return false;
               };
    </script>


你可以做这个jquery。这是您可以参考查询的完美示例。



http:/ /api.jquery.com/unload/ [ ^ ]



如果你想在按钮点击事件上这样做,你可以参考这个。

http://myclabs.github.io/jquery.confirm/



http://www.projectshadowlight.org/jquery-easy-confirm-dialog/ [ ^ ]
You can do this jquery. This is the perfect example you can refer for your query.

http://api.jquery.com/unload/[^]

If you want to do this on button click event you can refer this.
http://myclabs.github.io/jquery.confirm/

http://www.projectshadowlight.org/jquery-easy-confirm-dialog/[^]


这篇关于当我离开页面并浏览新页面时显示确认消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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