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

I believe he meant different sizes.

Notice how the position of the key item changes in the following two "browser windows":
foo foo foo foo foo keyword foo foo foo
foo foo foo foo foo keyword foo foo foo

Replies are listed 'Best First'.
Re^3: Position on Web Page
by Gavin (Archbishop) on Aug 19, 2007 at 16:49 UTC
    So to use your example the arrow is attached to the "keyword" but because of formatting the word position changes with window size.
    Then perhaps one way would be to combine text and "arrow pointer" into an image and display that in the browser
      This is quite clearly best solved by Javascript.

      Basically you want to draw your arrow (or whatever) so that its tip points to the area of interest.

      Best bet is to:

      1. find the area in question (say by using document.getElementById)
      2. compute the (possibly relative) position of the element node.
      3. reposition/reorient your pointer to point to it.
      The second step is generally a difficult problem for arbitrary DHTML documents in various browsers.

      I recommend the "walk up the tree" approach... which is basically just walking up the .parent chain from your interesting node until you find the first node that is absolutely positioned.. then you walk back down, asking the browser for the "computed" styles of each container element until you get to the target node, collecting positioning attributes on the way down. You should end up with a "recipe" for how to compute the position of the target-node. (A thorough understanding of DOM, CSSp and browser DOM-bugs is required... implementation left as an exercise for the reader ;)

      -David

        Hi, Thankyou everyone for your replies. I am able to compute the position of the element node. Now using the element node, I am able to compute the position of the node. However say my node is a paragraph:
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam tellus dui, pharetra nec, pharetra ut, congue non, mauris. Vestibulum id lorem sit amet pede faucibus aliquet. Nunc nec nunc. Sed nec dui placerat elit pulvinar congue. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient montes
        In the above table, as you resize the window, the position of "Placerat" word changes. Now if my arrow was pointing to say "Placerat", its position should always be maintained irrespecitve if the browser is resized or not. When the page is fixed design, this works fine. But when using a table with %, it does not work. Is there somehow I can permanently attach the arrow to a particular word. Thank you very much, Anant