Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript onclick=";返回SubmitConfirmation()&引用;提交按钮在chrome中不起作用_Javascript_Jquery_Google Chrome - Fatal编程技术网

javascript onclick=";返回SubmitConfirmation()&引用;提交按钮在chrome中不起作用

javascript onclick=";返回SubmitConfirmation()&引用;提交按钮在chrome中不起作用,javascript,jquery,google-chrome,Javascript,Jquery,Google Chrome,这在firefox中有效,在chrome中无效。这个问题看起来很奇怪 我有一个submit按钮,如下所示,它调用一个javascript函数,根据几个检查进行确认和提示 <input type="submit" value="Submit" class="btn btn-default" onclick="return SubmitConfirmation();" /> 在mozilla中,上述脚本可以正常工作。但是在chrome中,如果我有第二个if检查,它将不起作用。我想不出

这在firefox中有效,在chrome中无效。这个问题看起来很奇怪

我有一个submit按钮,如下所示,它调用一个javascript函数,根据几个检查进行确认和提示

 <input type="submit" value="Submit" class="btn btn-default" onclick="return SubmitConfirmation();" />
在mozilla中,上述脚本可以正常工作。但是在chrome中,如果我有第二个if检查,它将不起作用。我想不出这里出了什么问题

函数“SubmitConfirmation”将返回真/假。如果为真,则应提交。在chrome中,函数返回true,但提交没有发生。

if (_userConfirm != true)
//tried to use 
if(!_userConfirm)

即时通讯使用Chrome,66.0.3359.139(官方版本)(64位)。有虫子吗s

您正在执行此操作,只需单击一个按钮,它应该是表单的
onsubmit
,无需进一步更改

<form onsubmit="return SubmitConfirmation();">
#数据处理{
显示:无
}

处理

您最好使用
元素。addEventListener()
,因为它在大多数情况下更可靠

document.querySelector(“#我的提交”).addEventListener('click',函数(事件){
if(SubmitConfirmation()){
返回;
}否则{
event.preventDefault();
返回;
}
})
函数提交确认(){
showLoading();
var合计=0;
$(“.table success”)。每个(函数(){
total+=parseFloat($($input[id$='price'],this.val());
});
如果(总数>50000)
警告(“请附上详细信息!”);
var_userConfirm=confirm('您想继续吗?');
//如果下面的“if语句”不存在,则一切正常。
如果(_userConfirm!=true)
hideLoading();
返回用户确认;
}
函数showLoading()
{
$(“#divProcessing”).show();
$(“输入[类型=提交]”).attr(“已禁用”、“已禁用”);
}
函数hideLoading()
{
$(“#divProcessing”).hide();
$(“input[type=submit]”。removeAttr(“已禁用”);
}

在Chrome中,在调用
showLoading()
之前,启动了
确认
。因此,这里的诀窍是将确认代码移动到
setTimeout()
函数中以中断时间

顺便说一句,您不需要在
onclick=“return SubmitConfirmation();”

函数提交确认(){
showLoading();
var合计=0;
$(“.table success”)。每个(函数(){
total+=parseFloat($($input[id$='price'],this.val());
});
如果(总数>50000)
警告(“请附上详细信息!”);
setTimeout(函数(){
var_userConfirm=confirm('您想继续吗?');
//如果下面的“if语句”不存在,则一切正常。
如果(!\u用户确认){
hideLoading();
}
返回用户确认;
}, 200);
}
函数showLoading()
{   
$(“#divProcessing”).show();
$(“输入[类型=提交]”).attr(“已禁用”、“已禁用”);
}
函数hideLoading()
{
$(“#divProcessing”).hide();
$(“input[type=submit]”。removeAttr(“已禁用”);
}
#数据处理{
显示:无;
}


正在加载…
define“doesnot work”(您有一个缺少的引号)
hideLoading
包含什么?更新的问题您是否在
警报中看到缺少的引号(“请附上详细信息!);
?@Jamiec因此基本上,此函数将返回true/false。如果为true,则应提交。因此,函数将返回true,但提交不会发生。您是否需要
返回no()
sorry是XD之前的一次尝试。这不会阻止表单首先被发送。您绝对需要
返回
。此外,从
setTimeout
回调返回任何内容都是毫无意义的。这个答案再错不过了
<form onsubmit="return SubmitConfirmation();">