2011-12-31 190 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 :)