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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2 javascripts not working in 1 page.

    I need two or more javascripts in one page. But the problem is that when i put one or more javascript only the last one works while others donot work. But when single all work fine. What could be the problem?

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    try to combine the init() functions that define the two scripts into one new init(). Use alerts in each step to see where the eroor is coming from.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Or ... look for one (or all) of these:

    window.onload = something;
    onload = something;
    <body .... onload="something()">

    All are the same; they refer to a variable called 'onload.'
    Only one per customer.

    Read this.
    Last edited by adios; 05-20-2009 at 08:14 AM.

  • #4
    New Coder bigtiger's Avatar
    Join Date
    Oct 2005
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm...
    This may also work but should be used when none of works
    ie, document.attachEvent
    ff, document.addEventListener

    these will allow attach more than one even handler on a page.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,253
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    http://www.javascriptkit.com/javatut...iplejava.shtml

    It should be mentioned that another possible problem is duplication of one or more function and/or variable names between the two scripts.

  • #6
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks every body. I'll go thru all of ur steps and let u know what happened.


  •  

    Posting Permissions

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