开发者

IHTMLElement2.getBoundingClientRect() does not work correctly

开发者 https://www.devze.com 2022-12-08 17:16 出处:网络
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

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 hap开发者_开发问答pens 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消