Different behaviour between document.evaluate in Firefox and Chrome

176 views
Skip to first unread message

Alvis

unread,
Jul 4, 2010, 9:15:45 AM7/4/10
to Chromium-extensions
Hi,

I am new to using xpath and document.evaluate and I would like some
help with this. I'm trying to use an xpath expression in a
document.evaluate to get a div with the name titleInfoArea.

Below is the code containing everything and is ready to run in your
browser.
http://pastebin.com/4AcfN43T

In Firefox, result.singleNodeValue works and returns [object
HTMLDivElement], which is what I want. However in Chrome, it is null.
What is interesting is that I need to generate the HTML on-the-fly
with createElementByP, but if I put the HTML into the body of the
document and let the script do it's work, Chrome behaves as expected
returning the div, but for this project I need to generate the html so
that is not an option.

Any ideas as to what could be causing this?

Thanks.

Rots

unread,
Jul 6, 2010, 4:52:19 AM7/6/10
to Chromium-extensions
Works with
document.evaluate("*[@id='titleInfoArea']",alertmsg,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue

See also:
http://www.w3.org/TR/xpath/#unique-id

Rots

On Jul 4, 4:15 pm, Alvis <omgsplos...@gmail.com> wrote:
> Hi,
>
> I am new to using xpath and document.evaluate and I would like some
> help with this. I'm trying to use an xpath expression in a
> document.evaluate to get a div with the name titleInfoArea.
>
> Below is the code containing everything and is ready to run in your
> browser.http://pastebin.com/4AcfN43T
Reply all
Reply to author
Forward
0 new messages