in reply to Re^8: Position on Web Page
in thread Position on Web Page

Hi, Thankyou for the code you have written. But it may not necessarily be on text only. It could be anywhere on the page. I appreciate all the efforts you are all taking to solve my problem :) Thank you very much for all your reples. Anant

Replies are listed 'Best First'.
Re^10: Position on Web Page
by erroneousBollock (Curate) on Aug 22, 2007 at 04:19 UTC
    I wrote it to look for text because that's what you said you were having trouble targeting.

    Normally, you can just compute the offsets of a node recursively to find it's position (most cases), but text nodes (nodeType == 3) are computed at page-reflow time and do not contain positioning attributes.

    All I did was to find the text you were looking for, split it apart from the surrounding text and then wrap it in a <span> tag... which has positioning attributes and so can be tracked as per any other node.

    No single method of searching/targeting the page content will work for everything, so you need to understand the types of content you will be serving and then adapt your "pointer" targeting correspondingly.

    Basically, my goal was to help you understand the nature of the problem, and a reasonable approach to its solution... but you will definitely need to work on it yourself (possibly do some reading about javascript and DOM) before anyone can help you more.

    I can help you with your version of the code if you like... but this thread is a little long and off-topic, so perhaps the CB and your public scratchpad might be better venues ?

    -David