Problems getting attribute xlink:href in Safari browser

Discussion in 'Javascript' started by Lance Dyas, Oct 5, 2005.

  1. Lance Dyas

    Lance Dyas Guest

    I have managed to get the xml to load using the xmlHTTPrequest...
    (inspite of premature readyState 4) the problem now arises
    in Safari alone...

    var thelink = node.getAttribute("xlink:href")

    Works in other browsers... except Safari, where
    it always returns null

    Any ideas?


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Lance Dyas, Oct 5, 2005
    #1
    1. Advertising

  2. Lance Dyas wrote:


    > var thelink = node.getAttribute("xlink:href")


    Assuming the prefix xlink is bound to the namespace URI
    http://www.w3.org/1999/xlink you could try

    var theLink;
    if (typeof node.getAttributeNS != 'undefined') {
    theLink = node.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
    }
    else {
    theLink = node.getAttribute('xlink:href');
    }

    I don't have time to test that now with a Safari browser but if you are
    scripting XML with namespace then the namespace relevant methods of DOM
    Level 2 like getAttributeNS or getElementsByTagNameNS should be used if
    supported by the implementation.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Oct 5, 2005
    #2
    1. Advertising

  3. Lance Dyas

    Lance Dyas Guest

    Thanks for the response... my exposure to SVG and scripting within
    its various implementations had me trying almost exactly that as of a
    month ago there was no joy in Safari (or any other browser for the name
    space method), but since there have been a few Safari patches
    since then, I might give it another go.

    Martin Honnen wrote:
    >
    >
    > Lance Dyas wrote:
    >
    >
    >> var thelink = node.getAttribute("xlink:href")

    >
    > Assuming the prefix xlink is bound to the namespace URI
    > http://www.w3.org/1999/xlink you could try
    >
    > var theLink;
    > if (typeof node.getAttributeNS != 'undefined') {
    > theLink = node.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
    > }
    > else {
    > theLink = node.getAttribute('xlink:href');
    > }
    >
    > I don't have time to test that now with a Safari browser but if you are
    > scripting XML with namespace then the namespace relevant methods of DOM
    > Level 2 like getAttributeNS or getElementsByTagNameNS should be used if
    > supported by the implementation.
    >


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Lance Dyas, Oct 5, 2005
    #3
  4. Lance Dyas

    Lance Dyas Guest

    Just wanted to mention this worked quite nicely, it is a good sign when
    browsers do start paying attention to standards!

    Martin Honnen wrote:
    >
    >
    > Lance Dyas wrote:
    >
    >
    >> var thelink = node.getAttribute("xlink:href")

    >
    > Assuming the prefix xlink is bound to the namespace URI
    > http://www.w3.org/1999/xlink you could try
    >
    > var theLink;
    > if (typeof node.getAttributeNS != 'undefined') {
    > theLink = node.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
    > }
    > else {
    > theLink = node.getAttribute('xlink:href');
    > }
    >
    > I don't have time to test that now with a Safari browser but if you are
    > scripting XML with namespace then the namespace relevant methods of DOM
    > Level 2 like getAttributeNS or getElementsByTagNameNS should be used if
    > supported by the implementation.
    >


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Lance Dyas, Oct 6, 2005
    #4
  5. Lance Dyas

    Randy Webb Guest

    Lance Dyas said the following on 10/5/2005 8:15 PM:

    > Just wanted to mention this worked quite nicely, it is a good sign when
    > browsers do start paying attention to standards!


    Now, if we can just get posters to read and adhere to desired practices
    as explained in the groups FAQ. See signature below.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Answer:It destroys the order of the conversation
    Question: Why?
    Answer: Top-Posting.
    Question: Whats the most annoying thing on Usenet?
     
    Randy Webb, Oct 6, 2005
    #5
    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. Bernd Oninger
    Replies:
    1
    Views:
    565
    Henry S. Thompson
    Jun 30, 2004
  2. Harry Zoroc
    Replies:
    1
    Views:
    495
    Martin Honnen
    Aug 22, 2004
  3. adMjb
    Replies:
    2
    Views:
    632
    adMjb
    Jun 2, 2006
  4. Weston C

    Getting href attribute of <base> tag?

    Weston C, Jan 2, 2004, in forum: Javascript
    Replies:
    7
    Views:
    330
    Janwillem Borleffs
    Jan 4, 2004
  5. Mark Anderson
    Replies:
    4
    Views:
    182
    Mark Anderson
    Jan 6, 2004
Loading...

Share This Page