0

ここに、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>

そして、ここに私の機能があります

function confirm_message(){
         var response = confirm("Are you sure?");
    if(response){
      return false;
    }else{
             return false;
        }
}

基本的に、ユーザーが確認で「いいえ」をクリックした場合、他のjsを起動したくありません....しかし、他のすべてのjavascript

  $('contact_693_').show(); $('errors_693_').hide(); this.hide(); $('dont_693_').show();; return false;"

ユーザーが確認で「はい」または「いいえ」をクリックしても、まだ起動します...これを修正する方法についてのアイデア....

また、この埋め込み js は私が作成したものではなく、Ruby を使用してページ上に構築されています...

4

2 に答える 2

3

次のようなエラーをスローします。

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の処理を停止するはずです。

于 2012-04-27T01:52:49.903 に答える
2

確認機能にコードを含めます。

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:

<a style="padding: 5px;" onclick="confirm_then_execute()" id="the_link_693_" href="#" class="add_someone_else">Check it out</a>                 
于 2012-04-27T01:54:34.243 に答える