Central Javascript function file

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

    Central Javascript function file

    Hi all,

    I have several books on Javascript and, although they mention placing frequently used script
    functions in a central file and calling them from, there they don't explain how to call them.

    Can someone explain how I can call separate functions from a .js file that contains several
    functions from different webpages as they are needed?

    I've tried to do on my own it with no success.

    TIA,

    Susan
  • Dennis Marks

    #2
    Re: Central Javascript function file

    In article <6%Ykc.2367$Hs1 .1205@newsread2 .news.pas.earth link.net>,
    Susan <SusanL@bfd.net > wrote:
    [color=blue]
    > Hi all,
    >
    > I have several books on Javascript and, although they mention placing
    > frequently used script
    > functions in a central file and calling them from, there they don't explain
    > how to call them.
    >
    > Can someone explain how I can call separate functions from a .js file that
    > contains several
    > functions from different webpages as they are needed?
    >
    > I've tried to do on my own it with no success.
    >
    > TIA,
    >
    > Susan[/color]

    <script src="xxx.js" type="text/javascript"></script>

    Functions in a .js file work exactely as they do inline.
    function xxx(parm) {
    statements
    }

    To call say "xxx(parm)"

    I would not recommend putting all functions in one .js file since the
    entire file is downloaded even if only one function is used. Group by
    application.

    --
    Dennis Marks

    To reply change none to dcsi.


    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

    Comment

    • Susan

      #3
      Re: Central Javascript function file

      Dennis Marks wrote:[color=blue]
      > In article <6%Ykc.2367$Hs1 .1205@newsread2 .news.pas.earth link.net>,
      > Susan <SusanL@bfd.net > wrote:
      >
      >[color=green]
      >>Hi all,
      >>
      >>I have several books on Javascript and, although they mention placing
      >>frequently used script
      >>functions in a central file and calling them from, there they don't explain
      >>how to call them.
      >>
      >>Can someone explain how I can call separate functions from a .js file that
      >>contains several
      >>functions from different webpages as they are needed?
      >>
      >>I've tried to do on my own it with no success.
      >>
      >>TIA,
      >>
      >>Susan[/color]
      >
      >
      > <script src="xxx.js" type="text/javascript"></script>
      >
      > Functions in a .js file work exactely as they do inline.
      > function xxx(parm) {
      > statements
      > }
      >
      > To call say "xxx(parm)"
      >
      > I would not recommend putting all functions in one .js file since the
      > entire file is downloaded even if only one function is used. Group by
      > application.
      >[/color]
      Thank you, Dennis...

      Comment

      • Dr John Stockton

        #4
        Re: Central Javascript function file

        JRS: In article <6%Ykc.2367$Hs1 .1205@newsread2 .news.pas.earth link.net>,
        seen in news:comp.lang. javascript, Susan <SusanL@bfd.net > posted at Sun,
        2 May 2004 02:26:10 :[color=blue]
        >
        >Can someone explain how I can call separate functions from a .js file that
        >contains several
        >functions from different webpages as they are needed?[/color]

        See <URL:http://www.merlyn.demo n.co.uk/js-nclds.htm>.

        NOTE that, while an include file will probably contain mostly functions,
        it can contain any javascript, for example declarations and ordinary
        statements. It should probably contain at least a little comment, at
        least in the master copy.

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

        Comment

        Working...