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 5 of 5
  1. #1
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript fundamental question

    Dear friends,

    Would like to know if there is a in javascript use the capability of having the equivalent of 'cascading functions' so as to have functions be shared from a common place, similar to style sheets.

    If so, a link about it would be appreciated.

    Thanks.

    -mbl-

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    To have functions shared from a central location, put them into an external .js file. Otherwise you'll need to clarify what you mean.

  • #3
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by kansel
    To have functions shared from a central location, put them into an external .js file. Otherwise you'll need to clarify what you mean.
    Dear kansel,

    Am fairly new to this. So an external .js file maybe what's in mind, will check it out, or if you have a link.

    What's meant, though is, say there's 3 or so javascript functions that are used in most of the html pages. Well the thing is how to have those 3 functions in one single file and call them from each html page that needs them.

    Thanks.

    -mbl-

  • #4
    mbl
    mbl is offline
    New Coder
    Join Date
    Sep 2004
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dear Kansel,

    Found the info already. Yes, it'd be external js files. Just needed the right terminology for the search engine.

    Thanks.

    -mbl-

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    Yes, just put the functions into a plain text file and name it with a .js extension. Be sure to NOT include the <script></script> tags in that file.

    In your HTML files, call the .js file like so <script type="text/javascript" src="myfunctions.js"></script>


  •  

    Posting Permissions

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