如何在“退出"按钮上显示弹出消息 [英] how to show the popup message on Exit button

查看:43
本文介绍了如何在“退出"按钮上显示弹出消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似这样的按钮,我该怎么办?

I have a button something like this what should I do?

<input type="button" value="Exit" onclick="JavaScript:window.location.href='../index'"/>

在退出时,我将转到其他视图.

On Exit I am going to Other view..

在单击退出时,我需要显示一个弹出窗口,说您确定要退出吗?使用确定"和取消"按钮

On click on Exit I need to display popup window saying Are you sure you want to Exit? with Ok and Cancel buttons

有人告诉我要这样做吗?

anybody tell me out to do this?

谢谢

推荐答案

JavaScript:

<input type="button" value="Exit" onclick="confirmBox()" />

function confirmBox(){
  if (confirm('Are you sure you want to Exit?')){
    window.location.href = '../index'
  }
}

jQuery:

<input type="button" value="Exit" id="exit" />

$('#exit').click(function(){
   if (confirm('Are you sure you want to Exit?')){
     window.location.href = '../index'
   }
});

这篇关于如何在“退出"按钮上显示弹出消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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