SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lighbox onLoad Issue

    Hello

    I am using a JS Framework called Lightbox and everything works when I click a link to open the Lightbox. I am now trying to open this same Lightbox with the body onLoad method but it does not work. In Firefox, I get this error.

    $("overlay") has no properties

    Looking at the code, overlay seems to be a CSS element. Has anyone else experienced this issue and if so, how did you open a Lightbox on body onLoad?

    Thanks.

  2. #2
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not ideal, but I got something to work.

    In the body onLoad method, I call the window.setTimeout value. This seems to allow the page to load and then my lightbox window is displayed.

    <body onLoad=”window.setTimeout(‘startLightbox()’, 200);”>

    If you have any comments or concerns with this approach, I would like to hear about it. Also, if you have a better implementation, I would also like to hear about that was well.

  3. #3
    SitePoint Addict richtestani's Avatar
    Join Date
    Nov 2003
    Location
    Bridgeport
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sounds like maybe the Prototype framework isn't loading.
    RichTestani
    -------------------------------
    http://www.junkdepot.com
    http://www.rareoopdvds.com | The Movie Poster Site

  4. #4
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there something I can do to make sure the Prototype framework loads before body onLoad? Also, the error indicates overlay which is a css value. Is it possible the css file has not loaded yet?
    Last edited by TryingToLearn; Sep 30, 2007 at 18:15. Reason: Clarification

  5. #5
    SitePoint Addict richtestani's Avatar
    Join Date
    Nov 2003
    Location
    Bridgeport
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $('overlay') is a prototype shorthand for
    Code:
    document.getElementById('overlay');
    First you must include the script in your HTML, just like your Lightbox script using the <script> tags.

    Lightbox I believe can only be triggered through a click event. What is the code you have or onload event?
    RichTestani
    -------------------------------
    http://www.junkdepot.com
    http://www.rareoopdvds.com | The Movie Poster Site

  6. #6
    SitePoint Addict MarekS's Avatar
    Join Date
    Jan 2003
    Location
    Estonia / Tallinn
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by richtestani View Post
    Lightbox I believe can only be triggered through a click event. What is the code you have or onload event?
    I am also looking for a way to trigger lightbox on page load. Can it be done with lightbox at all? Can the click be faked? or is there any way to "click" without click?

    Thanks

    [EDIT]
    Found: http://www.bram.us/2007/07/30/my-cod...-on-page-load/

  7. #7
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My onLoad method brings up the Lightbox.

    Code:
    lb = new lightbox();
    lb.initCallable('div');
    lb.activate();


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
  •