【问题标题】:Javascript confirm box works in Chrome but not in Firefox and IEJavascript 确认框在 Chrome 中有效,但在 Firefox 和 IE 中无效
【发布时间】:2014-02-06 03:16:02
【问题描述】:

以下 javascript 在 chrome 中运行良好,但在 firefox 或 IE 中无法运行, 在我的例子中,我在 jQuery ajax 中执行了一些东西,并且 ajax 执行的文件会将这段代码回显到浏览器。

<script> 
 var con=confirm("Well Done, You have made a new sale. Click OK to proceed");
 if(con==true) {
  window.location.href="sales_supervisor.php"; 
 } 
 else 
 { 
  return false; 
 } 
</script>

它在 chrome 中运行良好,但在 Firefox 和 IE 中无法运行。

【问题讨论】:

  • 你可以只做if(con){...},因为con已经是一个布尔值,要么是真要么是假。

标签: javascript internet-explorer google-chrome firefox


【解决方案1】:

删除 else 条件,因为 return 只能在函数中使用...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多