views:

172

answers:

1

Hi all,

The getBoundingClientRect() does not work accurately for all cases. It fails when say a list of links that are side by side in a row and half of them are pushed to the next line because all the links cannot be fit into the same line. Now for the first link at the 2nd line the getBoundingClientRect() does not give correct results.

The value for IHTMLRect.bottom and IHTMLRect.right is correct, however the value for IHTMLRect.left and IHTMLRect.top corresponds to the first element in the first row.

How to get the exact coordinates for the first link in the second row?

This happens on say the google page or on the wikipedia page where there are bunch of language or location links.

For example, Links in the widipedia say,

Deutsch • English • Español • Esperanto • Français • Bahasa Indonesia • Italiano •

would be present in two lines like below because of layout.

Deutsch • English • Español • Esperanto • 
Français • Bahasa Indonesia • Italiano •

For this case the IHTMLElement2.getBoundingClientRect() works perfectly for everything except for Français.

I am not sure why this is happening, Any help or workaround for this problem is greatly appreciated.

Thanks,

Datte,

A: 

When I tried IHTMLElement2.getClientRects(). It provides the rectangles for inner contents of an element line by line. So this gets tricky to solve the problem.

dattebayo