function delete_all_check()
{
var prompt = window.confirm("Are you sure you want to delete all the local oui entries?");
if (prompt)
{
document.forms[0].refresh_in_progress.value = 1;
document.forms[0].refresh_key.value = 4;
document.forms[0].submit();
}
}我写了这样的函数,当我点击delete all时,有个框弹出,我点击取消,内容会被删掉,确定却删除不了,为什么?
{
var prompt = window.confirm("Are you sure you want to delete all the local oui entries?");
if (prompt)
{
document.forms[0].refresh_in_progress.value = 1;
document.forms[0].refresh_key.value = 4;
document.forms[0].submit();
}
}我写了这样的函数,当我点击delete all时,有个框弹出,我点击取消,内容会被删掉,确定却删除不了,为什么?
function delete_all_check()
{
var prompt = window.confirm("Are you sure you want to delete all the local oui entries?");
if (!prompt)
{
document.forms[0].refresh_in_progress.value = 1;
document.forms[0].refresh_key.value = 4;
document.forms[0].submit();
}
}
你点取消的话,,prompt为false;也就不会进if里面
加上!号就行了
if(confirm("Are you sure you want to delete all the local oui entries?"))
{
document.forms[0].refresh_in_progress.value = 1;
document.forms[0].refresh_key.value = 4;
document.forms[0].submit();
}
<script>
function myconfirm(){
if(!confirm("Are you sure you want to delete all the local oui entries?")){ return false; }
}
</script>
<form>
....................
<input type=submit id=a name=a value=删除 onclick='return myconfirm();'>
</form>onclick='return myconfirm();'
注意红字用法
onclick='return delete_all_check()'
因为确定后走了下面的代码,
document.forms[0].refresh_in_progress.value = 1;
document.forms[0].refresh_key.value = 4;
document.forms[0].submit();
这有影响吗?