address LINK object in the HEAD section

Discussion in 'Javascript' started by VK, Dec 20, 2005.

  1. VK

    VK Guest

    Having HEAD section like that:

    <head>

    <title>Foo</title>
    <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1">

    <link
    title="linkObject"
    rel="Alternate Appendix"
    type="text/plain"
    href="data.txt"
    charset="iso-8859-1"
    hreflang="en-US">

    </head>

    what would be the most realible way to get "linkObject" reference?

    var roof = document.getElementsByTagName('HEAD')[0];
    // ?
     
    VK, Dec 20, 2005
    #1
    1. Advertising

  2. VK wrote:

    > Having HEAD section like that:
    >
    > <head>
    >
    > <title>Foo</title>
    > <meta http-equiv="Content-Type"
    > content="text/html; charset=iso-8859-1">
    >
    > <link
    > title="linkObject"
    > rel="Alternate Appendix"
    > type="text/plain"
    > href="data.txt"
    > charset="iso-8859-1"
    > hreflang="en-US">
    >
    > </head>
    >
    > what would be the most realible way to get "linkObject" reference?
    >
    > var roof = document.getElementsByTagName('HEAD')[0];
    > // ?


    Replacing `title=' with `id=' and using Document::getElementById().


    PointedEars
     
    Thomas 'PointedEars' Lahn, Dec 20, 2005
    #2
    1. Advertising

  3. VK

    VK Guest

    Thomas 'PointedEars' Lahn wrote:
    > Replacing `title=' with `id=' and using Document::getElementById().


    Are ID's formally allowed for LINK? Or for other elements in the
    non-rendering section (HEAD) I did not find this attribute listed
    neither in W3C nor in MSDN. From the other side TITLE is required by
    W3C for alternate content links.

    Not to say I technically care too much but for some reasons I want to
    have this LINK usage free of any "hacking model" accusations. Unusual -
    yes, but fully standard compliant.
     
    VK, Dec 21, 2005
    #3
  4. VK wrote:

    > Thomas 'PointedEars' Lahn wrote:
    >> Replacing `title=' with `id=' and using Document::getElementById().

    >
    > Are ID's formally allowed for LINK? Or for other elements in the
    > non-rendering section (HEAD) I did not find this attribute listed
    > neither in W3C nor in MSDN.


    You must have a different "W3C" and "MSDN" than I have ;-)

    The `id' attribute is allowed for "All elements but BASE,
    HEAD, HTML, META, SCRIPT, STYLE, TITLE".
    See <URL:http://www.w3.org/TR/html4/index/attributes.html>

    ,-<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/id.asp>
    |
    | Applies To
    | [...] LABEL, LEGEND, LI, LINK, LISTING, [...]
    ^^^^
    The (X)HTML DTDs clearly state the `link' element has the `id' attribute:

    <URL:http://www.w3.org/TR/REC-html32#link>

    <http://www.w3.org/TR/html4/struct/links.html#edef-LINK>
    (note the `%attrs;' entity reference and follow the links
    <URL:http://www.w3.org/TR/html4/sgml/dtd.html#attrs>
    <URL:http://www.w3.org/TR/html4/sgml/dtd.html#coreattrs>)

    <URL:https://www.cs.tcd.ie/15445/15445.html#DTD>
    (search for "ATTLIST link")

    <URL:http://www.w3.org/TR/xhtml1/dtds.html#dtdentry_xhtml1-strict.dtd_link>
    (search for "ATTLIST link", note the `%attrs;' entity reference and follow
    the links)

    The `title' attribute, however, should provide for a short description of
    the element.

    <URL:http://www.w3.org/TR/html4/struct/global.html#adef-title>

    > From the other side TITLE is required by W3C for alternate content links.


    How do you got that idea?

    <URL:http://www.w3.org/TR/html4/struct/links.html#h-12.3.3>

    > Not to say I technically care too much


    But you should, for your own sake and that of users of your content.

    > but for some reasons I want to have this LINK usage free of any "hacking
    > model" accusations. Unusual - yes, but fully standard compliant.


    Accessing the `id' attribute value is sufficiently un"hack"ish :)


    PointedEars
     
    Thomas 'PointedEars' Lahn, Dec 21, 2005
    #4
  5. VK

    mrHoo Guest

    function getElementByAttribute(tagn,attrib,str){
    var A=document.getElementsByTagName(tagn);
    var O;
    var L=A.length;
    for(var i=0;i<L;i++){
    var tem=A;
    if(tem.getAttribute(attrib)&& tem.getAttribute(attrib)==str){
    O=tem;
    break;
    }
    }
    return O;
    }
     
    mrHoo, Dec 21, 2005
    #5
  6. VK

    mrHoo Guest

    function getElementsByAttribute(tagn,attrib,str){
    var A=document.getElementsByTagName(tagn);
    var O=new Array();;
    var L=A.length;
    for(var i=0;i<L;i++){
    var tem=A;
    if(tem.getAttribute(attrib)){
    if(str) tem.getAttribute(attrib)==str) O.push(tem);
    else O.push(tem);
    }
    return O;
    }
    // In your case you can call: getElementsByAttribute('link','title',str)
    (str is whatever you want to match)
     
    mrHoo, Dec 21, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian W
    Replies:
    10
    Views:
    785
    Brian W
    Jul 2, 2003
  2. Sergey Morkovkin
    Replies:
    5
    Views:
    17,337
    gamcfarlane
    Jul 14, 2009
  3. showme

    PHP and ASP.NET go HEAD to HEAD

    showme, Jul 8, 2004, in forum: ASP .Net
    Replies:
    13
    Views:
    738
    Sherif ElMetainy
    Jul 10, 2004
  4. Jiho Han

    Write into <HEAD></HEAD> section?

    Jiho Han, Jan 14, 2004, in forum: ASP .Net Building Controls
    Replies:
    6
    Views:
    240
    Sam Fields
    Jan 16, 2004
  5. Sergey Morkovkin

    Insert SCRIPT or LINK tag into a HEAD section DYNAMICALLY

    Sergey Morkovkin, Sep 11, 2003, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    196
    Slava Tihonyuk
    Sep 15, 2003
Loading...

Share This Page