Different behaviours when script included or called

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yves-Alain NICOLLET

    #1

    Different behaviours when script included or called

    How is it that when I include a script within a document it works and
    when I try to get it from my webserver it does not seem to work at
    all?

    I have documents on my webserver that contain a script of the form:

    <script language=JavaSc ript>
    javascript statements...
    </script>

    This works OK.

    When I put all the scripts statements in a file called
    /cgi-bin/myScript.js on the webserver and replace the script in the
    document with the phrase:

    <script language=text/JavaScript src=/cgi-bin/myScript.js></script>

    nothing works anymore.

    Any idea?
    Thanks.
  • Randy Webb

    #2
    Re: Different behaviours when script included or called

    Yves-Alain NICOLLET wrote:[color=blue]
    > How is it that when I include a script within a document it works and
    > when I try to get it from my webserver it does not seem to work at
    > all?
    >
    > I have documents on my webserver that contain a script of the form:
    >
    > <script language=JavaSc ript>
    > javascript statements...
    > </script>
    >
    > This works OK.
    >
    > When I put all the scripts statements in a file called
    > /cgi-bin/myScript.js on the webserver and replace the script in the
    > document with the phrase:
    >
    > <script language=text/JavaScript src=/cgi-bin/myScript.js></script>
    >
    > nothing works anymore.[/color]

    Because it should be:

    <script type="text/javascript" src="/cgi-bin/myScript.js"></script>

    There is no language text/JavaScript. Its type.



    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq/

    Comment

    • Peter Vernout

      #3
      Re: Different behaviours when script included or called


      "Randy Webb" <hikksnotathome @aol.com> wrote in message
      news:9YSdnb0V7a 3bYxXdRVn-tw@comcast.com. ..[color=blue]
      > Yves-Alain NICOLLET wrote:[color=green]
      > > How is it that when I include a script within a document it works and
      > > when I try to get it from my webserver it does not seem to work at
      > > all?
      > >
      > > I have documents on my webserver that contain a script of the form:
      > >
      > > <script language=JavaSc ript>
      > > javascript statements...
      > > </script>
      > >
      > > This works OK.
      > >
      > > When I put all the scripts statements in a file called
      > > /cgi-bin/myScript.js on the webserver and replace the script in the
      > > document with the phrase:
      > >
      > > <script language=text/JavaScript src=/cgi-bin/myScript.js></script>
      > >
      > > nothing works anymore.[/color]
      >
      > Because it should be:
      >
      > <script type="text/javascript" src="/cgi-bin/myScript.js"></script>
      >
      > There is no language text/JavaScript. Its type.
      >
      >
      >
      > --
      > Randy
      > Chance Favors The Prepared Mind
      > comp.lang.javas cript FAQ - http://jibbering.com/faq/[/color]

      It could also be that your webserver is trying to execute the js file
      instead of serving it to the browser for executing there (hence cgi-bin).
      try placing it on another path.


      Comment

      • Yves-Alain NICOLLET

        #4
        Re: Different behaviours when script included or called

        "Peter Vernout" <someone_not@mi crosoft.com> wrote in message news:<c6b0v5$3m 6$1@news.cistro n.nl>...[color=blue]
        > "Randy Webb" <hikksnotathome @aol.com> wrote in message
        > news:9YSdnb0V7a 3bYxXdRVn-tw@comcast.com. ..[color=green]
        > > Yves-Alain NICOLLET wrote:[color=darkred]
        > > > How is it that when I include a script within a document it works and
        > > > when I try to get it from my webserver it does not seem to work at
        > > > all?
        > > >
        > > > I have documents on my webserver that contain a script of the form:
        > > >
        > > > <script language=JavaSc ript>
        > > > javascript statements...
        > > > </script>
        > > >
        > > > This works OK.
        > > >
        > > > When I put all the scripts statements in a file called
        > > > /cgi-bin/myScript.js on the webserver and replace the script in the
        > > > document with the phrase:
        > > >
        > > > <script language=text/JavaScript src=/cgi-bin/myScript.js></script>
        > > >
        > > > nothing works anymore.[/color]
        > >
        > > Because it should be:
        > >
        > > <script type="text/javascript" src="/cgi-bin/myScript.js"></script>
        > >
        > > There is no language text/JavaScript. Its type.
        > >
        > >
        > >
        > > --
        > > Randy
        > > Chance Favors The Prepared Mind
        > > comp.lang.javas cript FAQ - http://jibbering.com/faq/[/color]
        >
        > It could also be that your webserver is trying to execute the js file
        > instead of serving it to the browser for executing there (hence cgi-bin).
        > try placing it on another path.[/color]

        I simply changed all that to:

        <script src=/scripts/myScript.js>

        and everything went smooth, since the webserver maps .js files to
        application/x-javascript.

        Thank you everybody.

        Comment

        • Michael Winter

          #5
          Re: Different behaviours when script included or called

          On 26 Apr 2004 01:41:38 -0700, Yves-Alain NICOLLET
          <Yves-Alain.Nicollet@ bull.net> wrote:

          [snip]
          [color=blue]
          > <script src=/scripts/myScript.js>[/color]

          That is still invalid. Not only because you omit a *required* type
          attribute, but you don't quote the src attribute value. It *is* necessary
          as only a limited character set can exist outside of quotes. A forward
          slash is one such excluded character. Whilst your browser might cope with
          it fine, not all will. As a general rule, quote *everything*. It's easier
          than remembering what's valid and what isn't.

          Mike

          --
          Michael Winter
          M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: Different behaviours when script included or called

            Yves-Alain NICOLLET wrote:
            [color=blue]
            > I simply changed all that to:
            >
            > <script src=/scripts/myScript.js>
            >
            > and everything went smooth, since the webserver maps .js files to
            > application/x-javascript.[/color]

            It is nevertheless incorrect. Unquoted attribute values must not contain
            the "/" character (attribute values that contain "/" must be quoted) and
            the "type" attribute is mandatory for valid HTML 4.


            PointedEars

            Comment

            Working...