Results 1 to 4 of 4

Thread: Firing an artificial load event for window

  1. #1
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Firing an artificial load event for window

    Main DD Script:
    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    Just a quick (I hope!) question. I'm making a site which injects content into a container div via the above script, and also makes use of the loadobjs method to load javascript and style sheets where relevant.

    The trouble I have is that some of the javascripts (lightbox and effects, prototype framework) rely on the window load event to instantiate the classes I need.

    And when the scripts are loaded via ajax they run but the neccesary trigger which instantiates the classes isn't hit, and I wondered if I could fire another Window.load event?

    So far my searching and experimentation has got me nowhere, and I wondered if anyone knew of a workaround (constrained by loading the scripts at an arbitary point after the initial page had loaded)?

    Thanks,

    Tim

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the quick reply, reading through it seems that the only object I can't use fireEvent on is the window object, guess I'll have to see if i can hack the scripts to be reliant on the document objects load instead

  4. #4
    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

    If you are using:

    http://www.dynamicdrive.com/dynamici...box2/index.htm

    You don't really want to re-init it over and over again. That would (in addition to initializing imported links) also add the lightbox framework elements to the page each time, confusing the heck out of many browsers.

    With lightbox and Ajax, I've been recommending this approach -

    Put the lightbox scripts and style links on the top page. On your external pages, use the hard coded onclick event with each lightbox link, ex (from the demo page, addition red):

    Code:
    <a href="images/image-1.jpg" rel="lightbox" onclick="myLightbox.start(this); return false;" title="my caption">image #1</a>
    - 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
  •