Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start a Lightbox on Page Load

Not sure exactly how to do this since I am not that great at Javascript.

Here is what I would like to do: A person goes to a page as soon as the page opens a lightbox opens automatically BEFORE the page loads any other content. The person will then read the information in the lightbox and have an a few options on how they want to proceed. While they read this information the rest of the page will load in the background.

How would I go about doing this?

Thanks!

Note: I am using Fancybox for my lightbox.

like image 855
L84 Avatar asked Dec 12 '25 00:12

L84


1 Answers

I would recommend prettyPhoto, I has a cool API that allows you to open the lightbox from javascript.

Following the API documentation here you can do something like this to launch lightbox on load using JS:

<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $().prettyPhoto()
    api_images = ['images/fullscreen/image1.jpg','images/fullscreen/image2.jpg','images/fullscreen/image3.jpg'];
    api_titles = ['Title 1','Title 2','Title 3'];
    api_descriptions = ['Description 1','Description 2','Description 3'];
    $.prettyPhoto.open(api_images,api_titles,api_descriptions);
  });
</script>

see my notes in this question:

jquery lightbox plugin: Bug on IE7 and IE8!

like image 62
Mo Valipour Avatar answered Dec 14 '25 13:12

Mo Valipour