external javascript question

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

    external javascript question

    I am having problem with external javascripts. My OS is XP Pro. I am told to
    create an external javascript using a .js extension. (I did that) The
    external .js is very simple, containing:

    function a_message()
    {
    alert('I came from an external script! Ha, Ha, Ha!!!!');
    }

    I am told to create an HTML page that accesses the .js script. (I did that).
    The web page is very simple, containing:

    <html>
    <head>

    <SCRIPT language="JavaS cript" SRC="jxt1.js"></SCRIPT>

    </head>
    </html>

    When I open the page, nothing happens.

    When I go to the .js file, to examine/edit it, and 'click' it, nothing
    happens.

    Do I have to do anything special to create and use external javascripts with
    XP Pro?

    This appears very basic but please answer. I need the ability to create an
    external javascript with a .js extension and have the HTMl pages access that
    external script?


  • Ivo

    #2
    Re: external javascript question

    "Chuck Mendell" wrote[color=blue]
    > I am having problem with external javascripts. My OS is XP Pro. I am told[/color]
    to[color=blue]
    > create an external javascript using a .js extension. (I did that) The
    > external .js is very simple, containing:
    >
    > function a_message()
    > {
    > alert('I came from an external script! Ha, Ha, Ha!!!!');
    > }
    >
    > I am told to create an HTML page that accesses the .js script. (I did[/color]
    that).[color=blue]
    > The web page is very simple, containing:
    >
    > <html>
    > <head>
    >
    > <SCRIPT language="JavaS cript" SRC="jxt1.js"></SCRIPT>
    >
    > </head>
    > </html>
    >
    > When I open the page, nothing happens.
    >[/color]

    You define a function a function in your script but never call that
    function.
    If your .js file contained only
    alert('I came from an external script! Ha, Ha, Ha!!!!');
    or
    function a_message()
    {
    alert('I came from an external script! Ha, Ha, Ha!!!!');
    }
    a_message(); // call your function here
    the alert should show up fine.

    BTW, the language attribute of script elements is deprecated and should be
    dropped in favour of the type attribute. This has nothing to do with your
    problem, but if you change
    <SCRIPT language="JavaS cript" SRC="jxt1.js"></SCRIPT>
    into
    <script type="text/javascript" SRC="jxt1.js"></script>
    then whoever told you to do these things might be silenced for a minute.
    HTH
    --
    Ivo


    Comment

    Working...