Results 1 to 9 of 9

Thread: Lightbox on Load of Website

  1. #1
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Lightbox on Load of Website

    1) Script Title:
    Lightbox 2.0
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...box2/index.htm
    3) Describe problem:
    Hello,

    I want to let Lightbox start when someone enter's my page

    Someone on a Dutch Forum has provided me the next code:
    Code:
    <html>
      <head>
        <script type="text/javascript">
          function openHomeImage()
          {
            eImage = document.getElementById('homeImage');
            myLightbox.start(eImage);
          }
          
          window.onload = openHomeImage;
        </script>
        <style type="text/css">
          #homeImageBox
          {
            display: none;
            visibility: hidden;
          }
        </style>
      </head>
      <body>
        <div id="homeImageBox">
          <img src="jouw_plaatje.jpeg" id="homeImage" rel="lightbox" />
        </div>
      </body>
    </html>
    I've editted my index.html, but it wouldn't work. The lightbox is showing up, but doesn't load the image.

    Can somebody help me?

  2. #2
    Join Date
    Feb 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default try this

    try:

    Code:
    <body onload="openHomeImage();">

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

  4. #4
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    as you can see in my page code i've already done this. And it doesn't work..

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Brent View Post
    as you can see in my page code i've already done this. And it doesn't work..
    Yes and no. I agree, your page doesn't work. I agree that perhaps you have read this thread I linked to in my previous post:

    http://www.dynamicdrive.com/forums/s...ad.php?t=27432

    and hopefully, particularly this post from it:

    http://www.dynamicdrive.com/forums/s...00&postcount=4

    I disagree that your page shows any attempt to follow the advice given there.

    I think perhaps you just missed my post or didn't look at the link in it, or perhaps didn't understand how it differs from what you've already tried.
    Last edited by jscheuer1; 02-13-2008 at 11:05 AM. Reason: spelling, emphasis
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, I didn't saw your message..

    I've editted ligthbox.js and also editted my index.html

    Code:
    <script type="text/javascript">
    
    function initLightbox()
          {
            eImage = document.getElementById('the_first');
            myLightbox.start(eImage);
          }
    </script>
    Code:
    <body bgcolor="#d6d6d6" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/pressed (7).jpg','images/pressed (8).jpg','images/pressed (9).jpg','images/pressed.jpg','images/pressed (2).jpg','images/pressed (3).jpg','images/pressed (4).jpg','images/pressed (5).jpg','images/pressed (6).jpg','images/pressed (10).jpg'); initLightbox();" >
    Code:
    <div id="homeImageBox">
          <img src="images/agenda/halfvrlarge.jpg" rel="lightbox" id="the_first" title="Upcoming.."/>
        </div>
    .. but still the image isn't loading yet...

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You are mixing apples and oranges in at least one, possibly more places. You cannot have this:

    Code:
    <img src="images/agenda/halfvrlarge.jpg" rel="lightbox" id="the_first" title="Upcoming.."/>
    even for a normal lightbox link. It has to be a link. More like:

    Code:
    <a href="images/agenda/halfvrlarge.jpg" rel="lightbox" id="the_first" title="Upcoming.."></a>
    Also, this (red):

    Code:
    <body bgc . . . eight="0" onLoad="MM_preload . . . ed (10).jpg'); initLightbox();" >
    is not required. Get rid of it. The lightbox script does that for you, without conflicting with other onload events.

    This isn't required:

    Code:
    <script type="text/javascript">
    
    function initLightbox()
          {
            eImage = document.getElementById('the_first');
            myLightbox.start(eImage);
          }
    </script>
    at all. Get rid of it. Instead, edit your lightbox.js file at the end replacing:

    Code:
    function initLightbox() { myLightbox = new Lightbox(); }
    Event.observe(window, 'load', initLightbox, false);
    with:

    Code:
    function initLightbox() { myLightbox = new Lightbox();
    var firstLight;
    if((firstLight=document.getElementById('the_first')) && /^lightbox/.test(firstLight.rel))
    firstLight.onclick.apply(firstLight);
     }
    Event.observe(window, 'load', initLightbox, false);
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a lot

    It's finally working now, I editted the .js before, bot not with that code. I've replaced it with another one from you're link, the first mentioned.

    Anyhow, thank you!

    EDIT: Is it possible to get 2 lightboxes on top of each other? So the users have te click 2 time on "close" before they can acces the page?
    Last edited by Brent; 02-13-2008 at 11:33 PM.

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Sorry I didn't get back to you Brent. I'm pretty sure that can be done. If you're still interested, start a new thread, as I'm closing this one.

    If anyone is still interested in the original topic (Lightbox on Load of Website), there has been for some time an unofficial Lightbox 2.04a 'firstlight' edition:

    http://www.dynamicdrive.com/forums/s...470#post163470
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •