我有一个确认框,用户可以选择确定继续,或者取消关闭框并保持在同一页面上。问题是,除了Opera之外的所有浏览器,如果我在确认框中单击取消,则框关闭,用户保持在同一页面上,这很好,但在Opera中,如果我点击取消它也会关闭页面。
如果我在确认框中单击“取消”,我需要包含哪些内容以便在Opera中关闭该框但不关闭该页面?
下面是代码:
function showConfirm(){
var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards your Session." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n" );
if (confirmMsg==true)
{
submitform();
}else{
parent.close();
}
}
由于
答案 0 :(得分:3)
在我看来,else
块不需要,因为元素的父级可以是window
。这就是页面关闭的原因。
我不确定你想用parent.close()
function showConfirm(){
var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards your Session." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n" );
if (confirmMsg)
{
submitform();
}
}
答案 1 :(得分:0)
单击确认框上的取消应该会关闭您的确认窗口,这是我认为您想要做的事情