1

ページの読み込み時に jQuery ライトボックスを読み込ませようとしています。途中まで来ました。ページが読み込まれるとライトボックスが開きますが、ページ全体と同じウィンドウでリンクが開きます。リンクを別のウィンドウにロードする前に、この時点で停止するにはどうすればよいですか。

jQuery:

$(document).ready(function(){
  $("a.greybox").bind("click", openbox);
  $("a.greybox").trigger('click', openbox);

  function openbox(){
    var t = this.title || $(this).text() || this.href;
    GB_show(t,this.href,340,220);
  }
})

HTML:

<a href="http://google.com/" title="Google" class="greybox">Launch Google</a>
4

2 に答える 2

1

次の行を含める場合:

return false;

あなたの機能で。これにより、リンクの元の動作が発生しなくなります。

于 2010-08-25T02:06:55.537 に答える
1
function openbox(evt){
    evt.preventDefault(); // <<-- Add this
    var t = this.title || $(this).text() || this.href; 
    GB_show(t,this.href,340,220);}
}
于 2010-08-25T01:30:45.187 に答える