"name" attribute.......more than one use?

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

    "name" attribute.......more than one use?

    <a href="#" name="sample">l ink 1</a>
    <a href="#" name="sample">l ink 2</a>

    Would this be invalid use of the name?
    If I wanted to have a function that would be acted upon by detection of the
    "name", would this happen if all "name"s in a group were the same?
    I know ID can only be used once per document, what about "name"?

    If this is invalid, then if I went by a unique ID, such as sample1, sample2,
    sampl3, is there a way to eliminate the number on the end to check if the
    strings match what I'm looking for?

    For those of you familiar with ancient BASIC, we could easily do this by
    saying something like A$=left$(b$,6).
    Where A$ would return the first 6 characters of b$.
    So does JS have an equivelant?


  • Lee

    #2
    Re: &quot;name&quot ; attribute...... .more than one use?

    Richard said:[color=blue]
    >
    ><a href="#" name="sample">l ink 1</a>
    ><a href="#" name="sample">l ink 2</a>
    >
    >Would this be invalid use of the name?
    >If I wanted to have a function that would be acted upon by detection of the
    >"name", would this happen if all "name"s in a group were the same?
    >I know ID can only be used once per document, what about "name"?[/color]

    The name attribute does not have to be unique.
    Your use is valid.

    [color=blue]
    >If this is invalid, then if I went by a unique ID, such as sample1, sample2,
    >sampl3, is there a way to eliminate the number on the end to check if the
    >strings match what I'm looking for?
    >
    >For those of you familiar with ancient BASIC, we could easily do this by
    >saying something like A$=left$(b$,6).
    >Where A$ would return the first 6 characters of b$.
    >So does JS have an equivelant?[/color]

    A=b.substr(0,6)

    Comment

    • Richard

      #3
      Re: &quot;name&quot ; attribute...... .more than one use?

      On 15 Jan 2005 19:43:42 -0800 Lee wrote:
      [color=blue]
      > Richard said:[/color]
      [color=blue][color=green]
      >><a href="#" name="sample">l ink 1</a>
      >><a href="#" name="sample">l ink 2</a>[/color][/color]
      [color=blue][color=green]
      >>Would this be invalid use of the name?
      >>If I wanted to have a function that would be acted upon by detection of
      >>the
      >>"name", would this happen if all "name"s in a group were the same?
      >>I know ID can only be used once per document, what about "name"?[/color][/color]
      [color=blue]
      > The name attribute does not have to be unique.
      > Your use is valid.[/color]

      [color=blue][color=green]
      >>If this is invalid, then if I went by a unique ID, such as sample1,
      >>sample2,
      >>sampl3, is there a way to eliminate the number on the end to check if
      >>the
      >>strings match what I'm looking for?[/color][/color]
      [color=blue][color=green]
      >>For those of you familiar with ancient BASIC, we could easily do this
      >>by
      >>saying something like A$=left$(b$,6).
      >>Where A$ would return the first 6 characters of b$.
      >>So does JS have an equivelant?[/color][/color]
      [color=blue]
      > A=b.substr(0,6)[/color]


      Thank you. I thought it must have.


      Comment

      • RobG

        #4
        Re: &quot;name&quot ; attribute...... .more than one use?

        Richard wrote:[color=blue]
        > <a href="#" name="sample">l ink 1</a>
        > <a href="#" name="sample">l ink 2</a>
        >
        > Would this be invalid use of the name?[/color]

        Yes - read the spec. In regard to <a> tags:

        "This attribute names the current anchor so that it may be the
        destination of another link. The value of this attribute must be a
        unique anchor name. The scope of this name is the current document.
        Note that this attribute shares the same name space as the id
        attribute."

        <URL:http://www.w3.org/TR/html4/struct/links.html#adef-name-A>

        All tag attributes and the tags that they apply to, along with links
        to explainations of each are here:

        <URL:http://www.w3.org/TR/html4/index/attributes.html >

        Whenever you are tempted to ask a question such as that above, read the
        spec first.

        [color=blue]
        > If I wanted to have a function that would be acted upon by detection of the
        > "name", would this happen if all "name"s in a group were the same?
        > I know ID can only be used once per document, what about "name"?[/color]

        Sometimes name must be unique, sometimes is should not be used and
        sometimes it is mandatory. Check the specification each time you want
        to use it.



        --
        Rob

        Comment

        • Fred Oz

          #5
          Re: &quot;name&quot ; attribute...... .more than one use?

          Lee wrote:[color=blue]
          > Richard said:
          >[color=green]
          >><a href="#" name="sample">l ink 1</a>
          >><a href="#" name="sample">l ink 2</a>
          >>[/color][/color]
          [...][color=blue]
          >
          > The name attribute does not have to be unique.
          > Your use is valid.[/color]

          Wrong. In regard to named links, the name attribute *must* be unique
          and it shares the same namespace as ID, so it must not match an ID
          either.

          --
          Fred

          Comment

          • Richard

            #6
            Re: &quot;name&quot ; attribute...... .more than one use?

            On Sun, 16 Jan 2005 14:48:37 +1000 RobG wrote:
            [color=blue]
            > Richard wrote:[color=green]
            >> <a href="#" name="sample">l ink 1</a>
            >> <a href="#" name="sample">l ink 2</a>[/color][/color]
            [color=blue][color=green]
            >> Would this be invalid use of the name?[/color][/color]
            [color=blue]
            > Yes - read the spec. In regard to <a> tags:[/color]
            [color=blue]
            > "This attribute names the current anchor so that it may be the
            > destination of another link. The value of this attribute must be a
            > unique anchor name. The scope of this name is the current
            > document.
            > Note that this attribute shares the same name space as the id
            > attribute."[/color]
            [color=blue]
            > <URL:http://www.w3.org/TR/html4/struct/links.html#adef-name-A>[/color]
            [color=blue]
            > All tag attributes and the tags that they apply to, along with links
            > to explainations of each are here:[/color]
            [color=blue]
            > <URL:http://www.w3.org/TR/html4/index/attributes.html >[/color]
            [color=blue]
            > Whenever you are tempted to ask a question such as that above, read
            > the
            > spec first.[/color]


            I would if I knew how w3 was structured to find these things out.
            Like they make it so easy.
            I thought it had to be unique but I wasn't sure if that was correct or not.


            Comment

            • RobG

              #7
              Re: &quot;name&quot ; attribute...... .more than one use?

              Richard wrote:
              [...][color=blue][color=green]
              >> Whenever you are tempted to ask a question such as that above, read
              >>the
              >> spec first.[/color]
              >
              >
              >
              > I would if I knew how w3 was structured to find these things out.
              > Like they make it so easy.
              > I thought it had to be unique but I wasn't sure if that was correct or not.
              >[/color]

              Here is the start of the W3C HTML 4.01 spec. It is the table of
              contents and has links to everything to do with HTML.

              <URL:http://www.w3.org/TR/html4/>

              At the bottom are links to references, notably a list of all the
              elements and all the attributes.

              The only way to get to know it is to start using it - think of an
              element, say <p> and look it up, it's in chapter 9, titled:

              "Text - Paragraphs, Lines, and Phrases"

              Click the link, it takes you here:

              <URL:http://www.w3.org/TR/html4/struct/text.html>

              Or, to go via the Index of elements, go to the bottom of the table of
              contents (where references are normally listed), and click on the link
              to here:

              <URL:http://www.w3.org/TR/html4/index/elements.html>

              scroll down to "P", click on it and you go here:

              <URL:http://www.w3.org/TR/html4/struct/text.html#edef-P>

              Now you know how I use it, try it.


              --
              Rob.

              Comment

              Working...