2011-12-31 156 views

回答

1
<script type="text/javascript"> 
     // Automagically load Lightbox on Page Load - by Bramus! (http://www.bram.us/) 
     // Code modded from http://www.huddletogether.com/forum/comments.php?DiscussionID=1269&page=1#Item_0 
     function autoFireLightbox() { 
      //Check if location.hash matches a lightbox-anchor. If so, trigger popup of image. 
      setTimeout(function() { 
       if(document.location.hash && $(document.location.hash.substr(1)).rel.indexOf('lightbox')!=-1) { 
        myLightbox.start($(document.location.hash.substr(1))); 
       }}, 
       250 
      ); 
     } 
     Event.observe(window, 'load', autoFireLightbox, false); 
</script> 
+1

你从哪里得到'myLightbox'? – 2016-02-18 15:28:31

0

或者是这样的:

$(function(){ 
    // Link to open 
    $("#link").click(); 
}); 

您确实需要首先初始化的fancybox,然后才能打开的fancybox。

现场演示:http://jsfiddle.net/Y554b/1/

0

我有一个简单的链接,包括“/ lightbox2”在网址的结尾,而“相对”属性。

<a id='popup' href="url/lightbox2" rel="lightframe">&nbsp;</a> 

和JS是这样的:

<script type='text/javascript'> 
$(function() { 
    $('#popup').trigger('click'); 
}); 
</script> 

要一次表现出来,或者一会儿我用jQuery.cookie :)