window.onload Issue

Discussion in 'HTML & Website Design' started by Qal, Aug 27, 2007.

  1. #1
    Hi,

    I've two Javascripts that seem to be conflicting with each other. Just of them works due to the window.onload issue:

    First one has "window.onload=function()" and the other one "window.onload=stripe"

    Is there anyway I can get both these JS to work correctly in IE/FF/Safari?

    Any help greatly appreciated.

    Many Thanks.
     
    Qal, Aug 27, 2007 IP
  2. twistedspikes

    twistedspikes Notable Member

    Messages:
    5,694
    Likes Received:
    293
    Best Answers:
    0
    Trophy Points:
    280
    #2
    stripe - could you put that inside the functon in the first one?

    Sorry not really a js guru, just know a wee bit
     
    twistedspikes, Aug 27, 2007 IP
  3. Qal

    Qal Peon

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Tried that already with no luck.
     
    Qal, Aug 27, 2007 IP
  4. twistedspikes

    twistedspikes Notable Member

    Messages:
    5,694
    Likes Received:
    293
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Anyway we could see the file? Just to see whats going on?
     
    twistedspikes, Aug 27, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you have multiple scripts calling window.onload they're going to conflict with each other. What you need to do is create a function at the end of your script library, assign THAT function the window.onload event handler, and then call the functions from the rest of your script library inside that function instead.

    Here's an example:

    
    window.onload = function() {
    	firstfunction();
    	secondfunction();
    	thirdfunction();
    }
    
    Code (markup):
     
    Dan Schulz, Aug 27, 2007 IP