how to put javascript in a file

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

    how to put javascript in a file

    i'm just finishing a web page with a fair amount of javascript, or seems
    that way to me being my first attempt at this.

    for this particular page i'm not so concerned about 'hiding' the javascript
    but keep hearing references to putting it in a file to hide it and am
    not sure how to do that. i want the code to be executed at the client
    browser side, not back at the server


  • Douglas Crockford

    #2
    Re: how to put javascript in a file

    > for this particular page i'm not so concerned about 'hiding' the javascript[color=blue]
    > but keep hearing references to putting it in a file to hide it and am
    > not sure how to do that. i want the code to be executed at the client
    > browser side, not back at the server[/color]

    There are lots of good reasons to put your programs in .js files, and execute
    them with

    <script src="yourfilena me.js"></script>

    Put forget about hiding it. It won't stay hidden. Don't even think about it.



    Comment

    • George M Jempty

      #3
      Re: how to put javascript in a file

      bbxrider wrote:[color=blue]
      > i'm just finishing a web page with a fair amount of javascript, or seems
      > that way to me being my first attempt at this.
      > http://job1data.com/phsvolunteer.HTM
      > for this particular page i'm not so concerned about 'hiding' the javascript
      > but keep hearing references to putting it in a file to hide it and am
      > not sure how to do that. i want the code to be executed at the client
      > browser side, not back at the server[/color]

      I looked at your code. Just take all your code between your script tags
      and put it into it's own file with a .js extension. NOTE: do NOT put
      the script tags into this file, just everything in between them.

      Then change the script tag in your page to something like:

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

      Where example.js is the name of the file you created in the first step
      above.

      HTH

      George

      Comment

      • bbxrider

        #4
        Re: how to put javascript in a file

        thanx for your help, any suggestions or is there something like a default
        standard
        on which directory and its permissions to put the .js files for iis5.0, i'm
        my own administrator
        for now
        "bbxrider" <bbxrider1@comc ast.net> wrote in message
        news:Yep7b.2983 89$Oz4.89065@rw crnsc54...[color=blue]
        > i'm just finishing a web page with a fair amount of javascript, or seems
        > that way to me being my first attempt at this.
        > http://job1data.com/phsvolunteer.HTM
        > for this particular page i'm not so concerned about 'hiding' the[/color]
        javascript[color=blue]
        > but keep hearing references to putting it in a file to hide it and am
        > not sure how to do that. i want the code to be executed at the client
        > browser side, not back at the server
        >
        >[/color]


        Comment

        Working...