views:

64

answers:

2

I'm trying to get a jQuery lightbox to load up when a page loads. I got half way there. The lightbox opens when the page loads but then proceeds to open the link in the same window as a full page. How do I get it to stop at this point before loading the link in a separate window.

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>
A: 
function openbox(evt){
    evt.preventDefault(); // <<-- Add this
    var t = this.title || $(this).text() || this.href; 
    GB_show(t,this.href,340,220);}
}
dave mankoff
A: 

If you include the line:

return false;

in your function. That will stop the links original behaviour from firing.

marblegravy
im sure this would work, im finding its a bug with the emulator.
egfx