Help moving scripts Into Separate File

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

    #1

    Help moving scripts Into Separate File

    Can somebody help me move scripts into a separate file (ie JavaScript) so
    that I can simply call the script from the body... and have it execute.
    I've done simple (couple to several lines) ones before but I can't get this
    one to work. I posted the url on a free site. Ignore the advertising and
    popups. The url is www.angelfire.com/falcon/jcotest

    I created the folder and the name of the JavaScript file already. When you
    go the site, it simply gives you the option to select one item and the html
    will display the "translucen t scroller" that I want to put into a
    JavaScript. I hope this can be done.

    Thanks in advance.


  • mscir

    #2
    Re: Help moving scripts Into Separate File


    JCO wrote:[color=blue]
    > Can somebody help me move scripts into a separate file (ie JavaScript) so
    > that I can simply call the script from the body...[/color]

    1. copy everything in the transparent scroller javascript script from
    this page:



    into a file named "scroller.j s" (or whatever you want to call it, ending
    with the '.js' extension). Do not include the <script> or </script>
    lines in the .js file, include everything between them. The first line
    in scroller.js will be:

    //Translucent scroller- By Dynamic Drive

    the last line will be:

    window.onload=s tartit

    2. insert this line into your html where you want the scroller to appear:

    <script type="text/javascript" src="scroller.j s"></script>

    If scroller.js is not in the same folder as the html page that
    references it with the above line, you'll have to provide the path in
    'src='.

    Does that work?

    Mike

    Comment

    • JCO

      #3
      Re: Help moving scripts Into Separate File

      Okay, I've done this but I'm having a weird effect.

      First of all, instead of an onload, can't I just place this in the body
      <script> startit() </script>

      When I tried this, the display was unpredictable. Then I took this out and
      everything works okay.
      It works okay with out having the OnLoad. Why is this. What else could be
      triggering this?


      "mscir" <mscir@access4l ess.net> wrote in message
      news:1045rd3hbg 7f4e0@corp.supe rnews.com...[color=blue]
      >
      > JCO wrote:[color=green]
      > > Can somebody help me move scripts into a separate file (ie JavaScript)[/color][/color]
      so[color=blue][color=green]
      > > that I can simply call the script from the body...[/color]
      >
      > 1. copy everything in the transparent scroller javascript script from
      > this page:
      >
      >[/color]
      http://www.angelfire.com/falcon/jcot...tScroller.html[color=blue]
      >
      > into a file named "scroller.j s" (or whatever you want to call it, ending
      > with the '.js' extension). Do not include the <script> or </script>
      > lines in the .js file, include everything between them. The first line
      > in scroller.js will be:
      >
      > //Translucent scroller- By Dynamic Drive
      >
      > the last line will be:
      >
      > window.onload=s tartit
      >
      > 2. insert this line into your html where you want the scroller to appear:
      >
      > <script type="text/javascript" src="scroller.j s"></script>
      >
      > If scroller.js is not in the same folder as the html page that
      > references it with the above line, you'll have to provide the path in
      > 'src='.
      >
      > Does that work?
      >
      > Mike
      >[/color]


      Comment

      • mscir

        #4
        Re: Help moving scripts Into Separate File

        JCO wrote:
        [color=blue]
        > Okay, I've done this but I'm having a weird effect.
        > First of all, instead of an onload, can't I just place this in the body
        > <script> startit() </script>
        > When I tried this, the display was unpredictable. Then I took this out and
        > everything works okay.
        > It works okay with out having the OnLoad. Why is this. What else could be
        > triggering this?[/color]

        1. don't top post, it messes up the q/a order of the post.

        2. see ans. #2 below, add the script refernce where you want that script
        embedded into your html page. There's no need to call anything in the
        body onload event in this case. The javascript from the .js file is
        inserted into your page where the reference to it is placed - the code
        runs the same as if you had placed the contents of the .js file in that
        location.


        [color=blue][color=green]
        >>2. insert this line into your html where you want the scroller to appear:
        >><script type="text/javascript" src="scroller.j s"></script>[/color][/color]


        Comment

        • JCO

          #5
          Re: Help moving scripts Into Separate File

          What do you mean by "don't top post"?

          I was under the impression that
          <SCRIPT LANGUAGE="JavaS cript1.2"
          src="../MyScripts/TranslucentScro ller.js"></SCRIPT>
          simply loads the script in memory so that all functions within the script
          can be invoked... when required.

          I was under the impression that it can be invoked either by
          <script> startit() </script>
          or
          onload = ?

          In general, is this a true assumption?


          "mscir" <mscir@access4l ess.net> wrote in message
          news:1045v0nt7t 9bt42@corp.supe rnews.com...[color=blue]
          > JCO wrote:
          >[color=green]
          > > Okay, I've done this but I'm having a weird effect.
          > > First of all, instead of an onload, can't I just place this in the body
          > > <script> startit() </script>
          > > When I tried this, the display was unpredictable. Then I took this out[/color][/color]
          and[color=blue][color=green]
          > > everything works okay.
          > > It works okay with out having the OnLoad. Why is this. What else could[/color][/color]
          be[color=blue][color=green]
          > > triggering this?[/color]
          >
          > 1. don't top post, it messes up the q/a order of the post.
          >
          > 2. see ans. #2 below, add the script refernce where you want that script
          > embedded into your html page. There's no need to call anything in the
          > body onload event in this case. The javascript from the .js file is
          > inserted into your page where the reference to it is placed - the code
          > runs the same as if you had placed the contents of the .js file in that
          > location.
          >
          >
          >[color=green][color=darkred]
          > >>2. insert this line into your html where you want the scroller to[/color][/color][/color]
          appear:[color=blue][color=green][color=darkred]
          > >><script type="text/javascript" src="scroller.j s"></script>[/color][/color]
          >
          >[/color]


          Comment

          Working...