Element attribute syntax question

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

    Element attribute syntax question

    I have look in the FAQ, Flanagan's "The definitive guide", and others,
    and I am not sure that the following syntax is valid (it is accepted by
    both IE and Firefox)
    <code>
    ....
    onload="javascr ipt:someFunctio nCall();"
    ....
    </code>

    I am objecting to the use of 'javascript:'.

    Thanks
    --
    intrader
  • Joost Diepenmaat

    #2
    Re: Element attribute syntax question

    intrader <intrader@aol.c omwrites:
    I have look in the FAQ, Flanagan's "The definitive guide", and others,
    and I am not sure that the following syntax is valid (it is accepted
    by both IE and Firefox)
    <code>
    ...
    onload="javascr ipt:someFunctio nCall();"
    ...
    </code>
    >
    I am objecting to the use of 'javascript:'.
    It's ugly and unnecessary, yes. It *is* valid javascript, though, since
    it's interpreted as a labeled statement (the label being "javascript ").

    Usually you don't want to use strings as event handlers anyway. IOW:
    use

    onload=someFunc tionCall;

    instead.

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

    Comment

    • VK

      #3
      Re: Element attribute syntax question

      On Mar 22, 10:03 pm, intrader <intra...@aol.c omwrote:
      I have look in the FAQ, Flanagan's "The definitive guide", and others,
      and I am not sure that the following syntax is valid (it is accepted by
      both IE and Firefox)
      <code>
      ...
      onload="javascr ipt:someFunctio nCall();"
      ...
      </code>
      >
      I am objecting to the use of 'javascript:'.
      Yes, it is valid Javascript syntax for a labeled statement:
      A labeled statement is any statement that is prefixed with an identifier. You can jump to this label using a break or continue statement nested within the labeled statement.


      It doesn't have any programmatical sense outside of loop blocks, so
      respectively it is valid but pointless for the Javascript itself in
      onload="javascr ipt:someFunctio nCall();"

      The reason one sees it sometimes is that Microsoft has added extra
      feature to the label: in intrinsic event handlers it informs the
      engine that the following code is JScript and not VBScript.
      Respectively it has practical sense only if one has a page viewed in
      Internet Explorer, the default scripting language on the page is set
      to VBScript, yet some intrinsic event handlers has to be written in
      JScript. Unless you need to deal with such ugliness, you don't need
      "javascript :" prefix.

      Comment

      • intrader

        #4
        Re: Element attribute syntax question

        VK wrote:
        On Mar 22, 10:03 pm, intrader <intra...@aol.c omwrote:
        >I have look in the FAQ, Flanagan's "The definitive guide", and others,
        >and I am not sure that the following syntax is valid (it is accepted by
        >both IE and Firefox)
        ><code>
        >...
        >onload="javasc ript:someFuncti onCall();"
        >...
        ></code>
        >>
        >I am objecting to the use of 'javascript:'.
        >
        Yes, it is valid Javascript syntax for a labeled statement:
        A labeled statement is any statement that is prefixed with an identifier. You can jump to this label using a break or continue statement nested within the labeled statement.

        >
        It doesn't have any programmatical sense outside of loop blocks, so
        respectively it is valid but pointless for the Javascript itself in
        onload="javascr ipt:someFunctio nCall();"
        >
        The reason one sees it sometimes is that Microsoft has added extra
        feature to the label: in intrinsic event handlers it informs the
        engine that the following code is JScript and not VBScript.
        Respectively it has practical sense only if one has a page viewed in
        Internet Explorer, the default scripting language on the page is set
        to VBScript, yet some intrinsic event handlers has to be written in
        JScript. Unless you need to deal with such ugliness, you don't need
        "javascript :" prefix.
        >
        Thank you, I understand the meaning of the syntax and I did not think of
        labels as they are so rarely used.
        Would two attributes with the same label be considered duplicate, or are
        they in a different scope?

        --
        intrader

        Comment

        Working...