Javascript中的确认框 [英] Confirm box in Javascript

查看:79
本文介绍了Javascript中的确认框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在aspx页面中有确认框

我的要求是在确认框中单击确定",关闭浏览器,如果单击取消",留在同一页面上.

但是我尝试过,在我的脚本问题中可以正常工作,但是如果单击取消",它不会停留在同一页面上,则只是关闭.

Hi,

I have confirm box in my aspx page

My requirement is at that confimation box if we click ok browser closed and if we click cancel stay on the same page

but i tried ,in my script problem is ok is working fine but if click cancel its not stay in same page its just closed.

var msg = confirm("\''Do You Really Want to Close?\''");
                    if (msg) {
                        window.close();                    
                    }
                    else {
                        return;                     
                    }



请帮助我解决此问题

提前提醒您........



please help me to fix this problem

Tnak you in advance........

推荐答案



您可以返回false,然后它将仅停留在当前页面上.其他方面,您可以发出警报以检查其是否进入其他部分
像这样

Hi,

You can return false then it will stays on current page only. other wise in else part you can put alert to check its coming to else part or not
like this

function confirmation() {
    var answer = confirm(window.close());
    if (answer){
        alert("Bye bye!")
        window.location = "http://www.yahoo.com/";
    }
    else{
        alert("Thanks for sticking around!")
    }
}


这篇关于Javascript中的确认框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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