Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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-如何停止执行_Javascript_Jquery - Fatal编程技术网

Javascript-如何停止执行

Javascript-如何停止执行,javascript,jquery,Javascript,Jquery,这是我与嵌入式js的链接 <a style="padding: 5px;" onclick="confirm_message(); $('contact_693_').show(); $('errors_693_').hide(); this.hide(); $('dont_693_').show();; return false;" id="the_link_693_" href="#" class="add_someone_else">Check it out</a>

这是我与嵌入式js的链接

<a style="padding: 5px;" onclick="confirm_message(); $('contact_693_').show(); $('errors_693_').hide(); this.hide(); $('dont_693_').show();; return false;" id="the_link_693_" href="#" class="add_someone_else">Check it out</a>
基本上,如果用户在确认中单击“否”,我不希望任何其他js触发……但是所有其他javascript

  $('contact_693_').show(); $('errors_693_').hide(); this.hide(); $('dont_693_').show();; return false;"
无论用户在“确认”中单击“是”或“否”,仍会激发…关于如何修复此问题的任何想法


另外,这个嵌入式js不是我创建的,而是用ruby在页面上构建的…

抛出一个错误,如下所示:

function confirm_message(){
    var response = confirm("Are you sure?");
    if(response){
      return false;
    }else{
         throw new Error("Chuck Norris roundhouse kicked your JS, sorry."); // or something a little more descriptive
    }
}

这并不漂亮,但应该会阻止所有未来的JS处理。

抛出一个错误,如下所示:

function confirm_message(){
    var response = confirm("Are you sure?");
    if(response){
      return false;
    }else{
         throw new Error("Chuck Norris roundhouse kicked your JS, sorry."); // or something a little more descriptive
    }
}

这并不漂亮,但应该会阻止所有未来的JS处理。

在确认函数中包含您的代码:

function confirm_then_execute(){    
     var response = confirm("Are you sure?");    
     if(response){
         $('contact_693_').show(); $('errors_693_').hide();this.hide(); $('dont_693_').show();return false;"
     }
     else{    
         return false;    
    }
}
html:


在确认功能中包括您的代码:

function confirm_then_execute(){    
     var response = confirm("Are you sure?");    
     if(response){
         $('contact_693_').show(); $('errors_693_').hide();this.hide(); $('dont_693_').show();return false;"
     }
     else{    
         return false;    
    }
}
html:



您可以发布生成此代码的ruby代码吗?是Rails吗?你能发布生成这个的ruby代码吗?是Rails吗?我不能这样做,因为我在js级别上没有那些div ID和类。如何将ID作为参数传递:confirm_then_execute(id1,id2)?我不能这样做,因为我在js级别上没有那些div ID和类。如何将ID作为参数传递:confirm_then_execute(id1,id2)?抛出错误将如何帮助用户…我只希望框关闭,而另一个js不会启动。@Matt:抛出错误将导致页面上所有其他Javascript停止执行。这包括“其他js”。没问题,很高兴我能提供帮助。抛出一个错误对用户有什么帮助……我只想关闭这个框,而不触发其他js。@Matt:抛出一个错误将导致页面上所有其他Javascript停止执行。包括“其他js”。没问题,很高兴我能帮上忙。