开发者

Getting actual widh/height values of element via attributes.getNamedItem

i am tring to get the width/height values of an element in dom tree (HTML page) and i am using below method:

var event = e || window.event;

var target = event.target || event.srcElement;

i am getting id and class information by using

var classinfo = target.attributes.getNamedItem("class").nodeValue;

var idinfo = targe开发者_运维问答t.attributes.getNamedItem("id").nodeValue;

but as you can guess, any elemen doesn't have to has id and/or class nodes so i can't check width="..px" node value or getElementById method

As a result, is there any way to get width and height values of a node element by using getNamedItem method / or any other you can advise.

NOTE: I need to get real width and height not css or inline because maybe width is 60% in css but it is rendered as 100px...

Thanks in advance.


element.offsetWidth, element.offsetHeight: overall size of the containing box in pixels

element.clientHeight, element.clientWidth: content dimensions

These are read only properties, and always return the current rendered values.

(You need to assign a style property in the element or in a stylesheet to set most elements onscreen height and width.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜