Why do this? <SCRIPT TYPE="text/javascript"

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

    Why do this? <SCRIPT TYPE="text/javascript"

    Hi;

    I've being going through some legacy code on an old JSP site I have
    been patching. I noticed that when I save the JSP down to my PC as an
    HTML file I get this javascript error in IE 6 ( not in the latest
    Firefox ):

    "invalid character"

    The problem traces back to this line of code:

    <SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>

    It goes away if I remove the "text/".

    I have never seen a script tag with "TYPE" or "text/javascript"
    used. Only "language = "javascript ""

    What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?

    Thanks in advance









  • Thomas 'PointedEars' Lahn

    #2
    Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

    Steve wrote:
    I've being going through some legacy code on an old JSP site I have
    been patching. I noticed that when I save the JSP down to my PC as an
    HTML file I get this javascript error in IE 6 ( not in the latest
    Firefox ):
    >
    "invalid character"
    >
    The problem traces back to this line of code:
    >
    <SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>
    Chances are a resource with the relative URI abc/jsp/blah.js simply does not
    exist (because you have missed downloading it to the appropriate location in
    the local filesystem), in which case the error message generated by the user
    agent or the Web server does not constitute a syntactically correct program.
    It goes away if I remove the "text/".
    Probably because the script is never loaded then.
    I have never seen a script tag with "TYPE" or "text/javascript" used.
    Then you have seen either only Valid HTML 3.2, where the `script' _element_
    has no attributes, or a lot of invalid HTML code.
    Only "language = "javascript ""
    But using that ranges from being deprecated to invalid nowadays.
    What is <SCRIPT TYPE="text/javascript" used for?
    To include code written in and for client-side ECMAScript implementations .
    Is it necessary?
    The `type' attribute of the `script' element is required, and a MIME media
    type is required as its value, since HTML 4.0:




    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

    Comment

    • Richard Cornford

      #3
      Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

      Steve wrote:
      I've being going through some legacy code on an old JSP
      site I have been patching. I noticed that when I save
      the JSP down to my PC as an HTML file I get this
      javascript error in IE 6 ( not in the latest
      Firefox ):
      >
      "invalid character"
      >
      The problem traces back to this line of code:
      >
      <SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>
      That error usually means that the SRC's URL does not refer to an
      existing resource, and the resulting 404 error page is HTML which when
      interpreted as javascript source code will produce one form of syntax
      error or another.
      It goes away if I remove the "text/".
      Yes, you have then prevented the browser from recognising the type of
      script and so it is not passing it into its javascript interpreter and
      so not finding the HTML that it is receiving erroneous when interpreted
      as javascript.
      I have never seen a script tag with "TYPE" or "text/javascript"
      used.
      Then you had best leave web development to someone with a little more
      relevant experience.
      Only "language = "javascript ""
      The language attribute of SCRIPT elements is deprecated in HTML 4 and
      not usable with strict (x)HTML DTDs.
      What is <SCRIPT TYPE="text/javascript" used for?
      The type attribute is required in valid HTML and is used to declare the
      type of script language used.
      Is it necessary?
      For valid mark-up it is required, in a purely practical sense it is not
      necessary. Most browsers will default to assuming javascript is the type
      of script language to use unless told something else, and most browsers
      can cope with defective/non-valid (a.k.a. 'tag soup') HTML mark-up to
      some degree or another. On the other hand, using mark-up that it at
      minimum structurally valid can avoid issues when attempting to script
      the resulting DOM, and having formally valid mark-up is one way of
      guaranteeing that the mark-up is structurally valid.

      Richard.

      Comment

      • Stevo

        #4
        Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

        Thomas 'PointedEars' Lahn wrote:
        Steve wrote:
        >Only "language = "javascript ""
        But using that ranges from being deprecated to invalid nowadays.
        PointedEars
        Which browser(s) treat language="javas cript" as invalid?

        Comment

        • sheldonlg

          #5
          Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

          Steve wrote:
          I have never seen a script tag with "TYPE" or "text/javascript"
          used. Only "language = "javascript ""
          That's the form I always use. In Dreamweaver, if you type <script and
          then a space, several choices come up and one is "type". Under that
          there are a few choices, the first of which is "text/javascript".
          >
          What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?
          >
          Thanks in advance
          >
          >
          >
          >
          >
          >
          >
          >
          >

          Comment

          • Peter Michaux

            #6
            Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

            On May 6, 1:35 pm, Steve <tinker...@gmai l.comwrote:
            Hi;
            >
            I've being going through some legacy code on an old JSP site I have
            been patching. I noticed that when I save the JSP down to my PC as an
            HTML file I get this javascript error in IE 6 ( not in the latest
            Firefox ):
            >
            "invalid character"
            >
            The problem traces back to this line of code:
            >
            <SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>
            >
            It goes away if I remove the "text/".
            That is strange. I've never had a problem. Is the "blah.js" file in
            some strange character encoding?

            I have never seen a script tag with "TYPE" or "text/javascript"
            used. Only "language = "javascript ""
            >
            What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?
            This is a bit of a tricky area. In mid 2006(?) the official type was
            approved as "applicatio n/javascript" however everyone had been using
            "text/javascript" and so there will be a transition period before
            using "applicatio n/javascript" is the norm.

            The type attribute is required by the HTML spec



            so if you want your page to validate as HTML

            W3C's easy-to-use markup validation service, based on SGML and XML parsers.


            you will need to include the type attribute.

            -----------

            Just in case you are new to validation, before you have a chance to
            get excited about XHTML for the general web


            An explanation of why XHTML may be a poor choice of document format in most cases.


            Also HTML 5 is almost surely the future of the web. XHTML just didn't
            have a good chance with how strict it is and without support in
            Internet Explorer, I guess.

            Peter

            Comment

            • RobG

              #7
              Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

              On May 7, 8:02 am, Stevo <n...@mail.inva lidwrote:
              Thomas 'PointedEars' Lahn wrote:
              Steve wrote:
              Only "language = "javascript ""
              But using that ranges from being deprecated to invalid nowadays.
              PointedEars
              >
              Which browser(s) treat language="javas cript" as invalid?
              Thomas isn't referring to browsers, he's talking about
              specifications. See Richard Cornford's reply to the OP.


              --
              Rob

              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

                Peter Michaux wrote:
                On May 6, 1:35 pm, Steve <tinker...@gmai l.comwrote:
                >I've being going through some legacy code on an old JSP site I have
                >been patching. I noticed that when I save the JSP down to my PC as an
                >HTML file I get this javascript error in IE 6 ( not in the latest
                >Firefox ):
                >>
                >"invalid character"
                >>
                >The problem traces back to this line of code:
                >>
                ><SCRIPT TYPE="text/javascript" SRC="abc/jsp/blah.js"></SCRIPT>
                >>
                >It goes away if I remove the "text/".
                >
                That is strange. I've never had a problem. Is the "blah.js" file in
                some strange character encoding?
                That would not matter, unless we are talking a misconfigured local Web
                server here which appears to be unlikely from the OP's description.
                Instead, it is very likely that the OP only stored the JSP and not the
                script, or they did not store it in the path where it belongs according to
                the above `script' element.
                >What is <SCRIPT TYPE="text/javascript" used for? Is it necessary?
                >
                This is a bit of a tricky area. In mid 2006(?) the official type was
                approved as "applicatio n/javascript" however everyone had been using
                "text/javascript" and so there will be a transition period before
                using "applicatio n/javascript" is the norm.
                Will you please get that right eventually? RFC4329 cause the registration
                of four media types for ECMAScript implementations , two especially for
                JavaScript:


                Also HTML 5 is almost surely the future of the web.
                Wishful thinking.
                XHTML just didn't have a good chance with how strict it is and without support in
                Internet Explorer, I guess.
                Quite the contrary. XHTML is continuously gaining speed on the Web despite
                that because people use XML-compliant tools to generate it and serve it to
                IE (and, unfortunately XHTML-compliant UA as well) as text/html instead.
                While that practice surely is debatable, it is a development reality.

                For example, we are mainly developing Plone-based Web sites (a decision made
                by one of my predecessors that I have to live with). A Zope Page Template
                (ZPT) that is required for efficient templating there (one wants to avoid
                DTML for non-trivial templates) is an XML application, and if HTML code is
                to be included it has to be XHTML or the template simply won't compile. So
                I have to serve Appendix-C-compatible XHTML 1.0 Transitional as text/html
                for those sites, knowing that I am relying on erroneous error-correction on
                the part of user agents.


                PointedEars
                --
                Prototype.js was written by people who don't know javascript for people
                who don't know javascript. People who don't know javascript are not
                the best source of advice on designing systems that use javascript.
                -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

                Comment

                • Laurent vilday

                  #9
                  Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

                  Thomas 'PointedEars' Lahn a écrit :
                  For example, we are mainly developing Plone-based Web sites (a decision made
                  by one of my predecessors that I have to live with). A Zope Page Template
                  Obviously, it can't be your responsability to have choosen such a thing.

                  So obvious.
                  (ZPT) that is required for efficient templating there (one wants to avoid
                  DTML for non-trivial templates) is an XML application, and if HTML code is
                  to be included it has to be XHTML or the template simply won't compile. So
                  I have to serve Appendix-C-compatible XHTML 1.0 Transitional as text/html
                  for those sites, knowing that I am relying on erroneous error-correction on
                  the part of user agents.
                  Muahahaha, shoot yourself in the foot (bad tools, change tools). And you
                  dare being a dick when other ppl are saying they do the same as you do.

                  Pathetic

                  --
                  laurent

                  Comment

                  • Peter Michaux

                    #10
                    Re: Why do this? &lt;SCRIPT TYPE=&quot;text/javascript&quot ;

                    On May 7, 3:19 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
                    wrote:
                    Peter Michaux wrote:
                    Also HTML 5 is almost surely the future of the web.
                    >
                    Wishful thinking.
                    I'm not sure why you need to be so cryptic so frequently and require
                    me asking you to complete your explaination. Anyway...what do you mean
                    by "wishful thinking"? Do you mean you think XHTML is the future or
                    HTML 4.1 will remain the standard or that tag soup is the only way
                    etc.

                    For example, we are mainly developing Plone-based Web sites (a decision made
                    by one of my predecessors that I have to live with). A Zope Page Template
                    (ZPT) that is required for efficient templating there (one wants to avoid
                    DTML for non-trivial templates) is an XML application, and if HTML code is
                    to be included it has to be XHTML or the template simply won't compile. So
                    I have to serve Appendix-C-compatible XHTML 1.0 Transitional as text/html
                    for those sites, knowing that I am relying on erroneous error-correction on
                    the part of user agents.
                    Hard to believe you rely on user-agent forgiveness based on all the
                    elitist posturing you do frequently. It's good you will admit it,
                    however, rather than fake purity.

                    Peter

                    Comment

                    Working...