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
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Javascripts

    Hi,

    I'm trying to add more than two Javascripts to one page.
    I have the following instructions but I really can't figure them out....

    Example of how to place more than one script on a webpage.

    Script 1 <body onload="dothis()">
    Script 2 <body onload="dothat()">

    Resolve by typing..<body onload=dothis();dothat()>


    Could anyone help me by converting these instructions into newbies language.

    I'd be very grateful for help.

    Many thanks.
    F.

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Flumoxed
    <body onload=dothis();dothat()>
    if you wrote proper HTML you wouldn't have a problem. you must always use quotations around attribute values. thus you should have written:

    Code:
    <body onload="dothis();dothat()">
    *keep it simple (TM)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,080
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    You say "more than two" JavaScripts. That is no problem.

    <body onload="dothis(); dothat(); dothethirdthing(); dothefourththing()">

    where of course dothis() etc. are replaced by the names of the functions
    you wish to call.

    Bear in mind that names of functions and variables must not be duplicated, so if (for example) two or more scripts have a (global) variable named x then mayhem is likely to occur. In other words, you may need to rename certain functions and/or variables.


  •  

    Posting Permissions

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