Multiple scripts on same HTML page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Kaplan

    Multiple scripts on same HTML page

    I know I can have multiple scripts on one HTML page (at least I think I know
    I can).

    i.e.

    <script language="Javas cript" type="text/javascript"
    src="../js/mainbutts.js"></script>
    ...html code...
    ...html code...
    <script language="Javas cript" type="text/javascript"
    src="../js/extrabutts.js"> </script>


    But the function names within each script, must they be unique? In other
    words both scripts have a function called "rollOver". Can that conflict?
    Should I rename them unique?

    Of course one might think, "Why doesn't this idiot try and see, rather than
    bother to ask?" But in my multiple decades of programming I've only learned
    one solid lesson: Just because it works one way, doesn't mean it's the
    right way to do it!

    Thanks ahead, as always.


  • Martin Honnen

    #2
    Re: Multiple scripts on same HTML page

    Daniel Kaplan wrote:
    I know I can have multiple scripts on one HTML page (at least I think I know
    I can).
    >
    i.e.
    >
    <script language="Javas cript" type="text/javascript"
    src="../js/mainbutts.js"></script>
    ...html code...
    ...html code...
    <script language="Javas cript" type="text/javascript"
    src="../js/extrabutts.js"> </script>
    >
    >
    But the function names within each script, must they be unique? In other
    words both scripts have a function called "rollOver". Can that conflict?
    Should I rename them unique?
    The latter function declaration will overwrite the former if both
    declare a function of the same name.
    Thus if you need both functions then you need different names.



    --

    Martin Honnen

    Comment

    Working...