Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts

    How do I get 2 scripts to work on a page? Newbie here!!

    Hi there this is my first post!!

    I have 2 scripts which I need to use on my webpage. Both scripts use the "window.onload=changecontent" command and this is causing a conflict between them.

    I am aware that I can remove the "window.onload=changecontent" command and put it into the "<body onload="something1();something2();"> event to stop conflicts, but how do get both to work when the "window.onload=changecontent" is the same for both scripts? I know I can't do "<body onload="changecontent();changecontent();">

    Any help would be greatly appreciated and this is my first post

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,302
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Welcome to the forum.

    You cannot have duplication of function or variable names between the two scripts.

    So you must rename the functions in the second script to something like:-

    "<body onload="changecontent1();changecontent2();">
    and similarly all the variables.

    But if the function changecontent() is identical why are two scripts needed? You might as well amalgamate or combine the two scripts into one.

  • #3
    Regular Coder
    Join Date
    Oct 2005
    Posts
    336
    Thanks
    43
    Thanked 2 Times in 2 Posts
    The two scripts for a horizontal scrolling banner and a menu, so they are different but both have the same "window.onload=populate" so I cant enter "populate" twice into the body script can I? Can I put populate1 and populate2?

    Sorry but Im really trying hard to get to grips with it all!!



  •  

    Posting Permissions

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