Simple IE xpath help

Discussion in 'Javascript' started by eggie5@gmail.com, Jan 23, 2007.

  1. Guest

    I know how to edit my page using xpath selectors in firefox, it's just
    like this (in the else if). However, I can't find any way to do it in
    IE? I just want to find all links with the className=='leftNavPElement'
    and then set them to 'leftNavBltItem', but I can't find how to do the
    xpath stuff in IE. Can somebody please fill in the if statment ie code
    for me?

    if (window.ActiveXObject)
    {

    //how do I do the code below for IE???
    }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation &&
    document.implementation.createDocument)
    {
    try
    {
    var layers =
    document.evaluate('//a[@class="leftNavPElement"]', document, null,
    XPathResult.ANY_TYPE, null );

    var thisLayer = layers.iterateNext();


    while (thisLayer) {

    thisLayer.className="leftNavBltItem";
    thisLayer = layers.iterateNext();


    }

    }
    catch(exception)
    {
    //this try catch is required for the
    leftnav to work for some reason....
    }
    }
    else
    {
    alert('errors in breadcrums.js line: 104');
    }
    , Jan 23, 2007
    #1
    1. Advertising

  2. wrote:
    > I know how to edit my page using xpath selectors in firefox, it's just
    > like this (in the else if). However, I can't find any way to do it in
    > IE? I just want to find all links with the className=='leftNavPElement'
    > and then set them to 'leftNavBltItem', but I can't find how to do the
    > xpath stuff in IE.


    Mozilla and Opera 9 support XPath over HTML DOM documents, IE does not
    do that. If you want to find all a elements with a certain className
    value then loop over document.getElementsByTagName('a') and check the
    className property in the loop.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 23, 2007
    #2
    1. Advertising

  3. Guest

    Thanks, don't know why I couldn't find that documented anywhere....

    On Jan 23, 5:10 am, Martin Honnen <> wrote:
    > wrote:
    > > I know how to edit my page using xpath selectors in firefox, it's just
    > > like this (in the else if). However, I can't find any way to do it in
    > > IE? I just want to find all links with the className=='leftNavPElement'
    > > and then set them to 'leftNavBltItem', but I can't find how to do the
    > > xpath stuff in IE.Mozilla and Opera 9 support XPath over HTML DOM documents, IE does not

    > do that. If you want to find all a elements with a certain className
    > value then loop over document.getElementsByTagName('a') and check the
    > className property in the loop.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
    , Jan 25, 2007
    #3
    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. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,969
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,403
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    520
  4. goog
    Replies:
    0
    Views:
    506
  5. Tjerk Wolterink

    XPath: efficiency in xpath expressions

    Tjerk Wolterink, Nov 13, 2004, in forum: XML
    Replies:
    1
    Views:
    1,626
    Richard Tobin
    Nov 13, 2004
Loading...

Share This Page