Accessing external Javascripts for information

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

    Accessing external Javascripts for information

    In an effort to turn a little more a module with my pages, I would

    like to turn my internal javascripts into an external javascript files

    to supply the information onto a web page.



    I still getting the hang of javascript, and I've searched the web, but

    I'm either putting the wrong key words into the search engines, or

    it can't be done. I've also done a quick search here, but some of

    the answers about external javascript examples seem to deal with

    issues of displaying CSS.



    Here's an example page that contains a javascript that I would like

    to turn into an external file:

    =============== =============== ===========

    <HTML><HEAD><TI TLE>Title of your page</TITLE>



    <script language="JavaS cript"><!--

    function dateString(oneD ate) {

    var theYear = oneDate.getFull Year()

    return theYear

    }//--></script>



    </HEAD><BODY>



    <p>This is the year:

    <script language="JavaS cript" type="text/JavaScript"[color=blue]
    >document.write (dateString(new Date()))</script>[/color]

    </p>



    </BODY></HTML>

    =============== =============== ===========



    If I can see how the simple example above is turned into an

    external file and accessed from within the page, then I should

    be able to figure out how to do my other scripts.



    Thanks for any insight.


    --
    Change [comcast.non] to [comcast.net]


  • Evertjan.

    #2
    Re: Accessing external Javascripts for information

    John B. wrote on 04 jul 2003 in comp.lang.javas cript:[color=blue]
    > If I can see how the simple example above is turned into an
    > external file and accessed from within the page, then I should
    > be able to figure out how to do my other scripts.[/color]

    Make a file called myjs.js with only(!!):

    function dateString(oneD ate) {
    return oneDate.getFull Year();
    };

    and call this in the <head> of yourhtml.html as:

    <script type="text/JavaScript"src= "\myjs.js">
    </script>

    Then later on in that same file's <body> you do:

    <script type="text/JavaScript">
    d = new Date();
    document.write( "This is the year: "+dateString(d) );
    </script>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    Working...