Home >Web Front-end >HTML Tutorial >Extract element dimensions from css stylesheet_html/css_WEB-ITnose

Extract element dimensions from css stylesheet_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:48:191044browse

jS function to get the value from the style sheet. In IE, it is obtained by currentStyle and defaultView in firefox.

DOM.style can only read the style value written in html

Function to get the style value

function returnStyle(obj,styleName){var myObj = typeof obj =="string" ? document.getElementById(obj) : obj;if(document.all){return eval("myObj.currentStyle."+ styleName);} else {returneval("document.defaultView.getComputedStyle(myObj,null)." +styleName);}}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn