Why no script type with onclick?

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

    Why no script type with onclick?

    Out of curiosity, when I use onclick="...som e JavaScript ..." why do I not
    need to flag that its JavaScript, but when I define a script on a page I do
    need to tag it (<script type="text/javascript">... )?

    Is it part of the standard that event handlers (onclick etc) are always
    JavaScript?

    Just curious. TIA.
    --
    Brian Cryer
    Brian Cryer's home page, a collection of notes on my professional and personal interests. Including C#, VB.Net, Windows, DB admin, Delphi and more.



  • Martin Honnen

    #2
    Re: Why no script type with onclick?

    Brian Cryer wrote:
    Out of curiosity, when I use onclick="...som e JavaScript ..." why do I not
    need to flag that its JavaScript, but when I define a script on a page I do
    need to tag it (<script type="text/javascript">... )?
    >
    Is it part of the standard that event handlers (onclick etc) are always
    JavaScript?
    The HTML 4 standard
    <URL:http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2.1>
    mandates that you provide a HTTP header or a meta element
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    but I don't know of browsers implementing that, they either support only
    JavaScript and therefore default to JavaScript in event handlers or
    (IE/Win) they have their own way of choosing the language: with IE the
    first script element and its language or type attribute determine the
    language for event handlers, additionally you can put the language in an
    attribute to indicate the language on a per element basis
    <input type="button" value="test" language="VBScr ipt"
    onclick="MsgBox window.event.ty pe">




    --

    Martin Honnen

    Comment

    • Brian Cryer

      #3
      Re: Why no script type with onclick?

      "Martin Honnen" <mahotrash@yaho o.dewrote in message
      news:47d7eb26$0 $6723$9b4e6d93@ newsspool3.arco r-online.net...
      Brian Cryer wrote:
      >Out of curiosity, when I use onclick="...som e JavaScript ..." why do I
      >not need to flag that its JavaScript, but when I define a script on a
      >page I do need to tag it (<script type="text/javascript">... )?
      >>
      >Is it part of the standard that event handlers (onclick etc) are always
      >JavaScript?
      >
      The HTML 4 standard
      <URL:http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2.1mandate s
      that you provide a HTTP header or a meta element
      <meta http-equiv="Content-Script-Type" content="text/javascript">
      but I don't know of browsers implementing that, they either support only
      JavaScript and therefore default to JavaScript in event handlers or
      (IE/Win) they have their own way of choosing the language: with IE the
      first script element and its language or type attribute determine the
      language for event handlers, additionally you can put the language in an
      attribute to indicate the language on a per element basis
      <input type="button" value="test" language="VBScr ipt"
      onclick="MsgBox window.event.ty pe">
      Thank you Martin.


      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Why no script type with onclick?

        Martin Honnen wrote:
        [...] with IE the first script element and its language or type attribute
        determine the language for event handlers, additionally you can put the
        language in an attribute to indicate the language on a per element basis
        <input type="button" value="test" language="VBScr ipt" onclick="MsgBox
        window.event.ty pe">
        However, that is not Valid HTML.


        PointedEars
        --
        var bugRiddenCrashP ronePieceOfJunk = (
        navigator.userA gent.indexOf('M SIE 5') != -1
        && navigator.userA gent.indexOf('M ac') != -1
        ) // Plone, register_functi on.js:16

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Why no script type with onclick?

          Thomas 'PointedEars' Lahn wrote:
          Martin Honnen wrote:
          >[...] with IE the first script element and its language or type attribute
          >determine the language for event handlers, additionally you can put the
          >language in an attribute to indicate the language on a per element basis
          ><input type="button" value="test" language="VBScr ipt" onclick="MsgBox
          >window.event.t ype">
          >
          However, that is not Valid HTML.
          <input type="button" value="test"
          onclick="vbscri pt: MsgBox window.event.ty pe">

          is. However, you don't want to use VBScript, not on the Web anyway as it's
          MSHTML-only (AFAIK).


          PointedEars
          --
          realism: HTML 4.01 Strict
          evangelism: XHTML 1.0 Strict
          madness: XHTML 1.1 as application/xhtml+xml
          -- Bjoern Hoehrmann

          Comment

          Working...