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!")
    }
}