如何使用JavaScript设置HTML元素的CSS背景颜色?
任何人都可以帮我一个脚本..或一种获得价值的方法
height : 1196px;
width: 284px;
Run Code Online (Sandbox Code Playgroud)
从计算样式表(webkit).我知道IE与往常不同.我无法访问iframe(跨域) - 我只需要高度/宽度.
我需要的屏幕截图(用红色圈出).我如何访问这些属性?

资源
<iframe id="frameId" src="anotherdomain\brsstart.htm">
<html id="brshtml" xmlns="http://www.w3.org/1999/xhtml">
\--I WANT THIS ELEMENTS COMPUTED BROWSER CSS HEIGHT/WIDTH
<head>
<title>Untitled Page</title>
</head>
<body>
BLA BLA BLA STUFF
</body>
</html>
\--- $('#frameId').context.lastChild.currentStyle
*This gets the actual original style set on the other domain which is "auto"
*Now how to getComputed Style?
</iframe>
Run Code Online (Sandbox Code Playgroud)
我得到的最接近的是这个
$('#frameId').context.lastChild.currentStyle
Run Code Online (Sandbox Code Playgroud)
这给了我HTML元素的实际样式,即"auto",这就是iframed文档中的设置.
如何获得所有浏览器用于计算滚动条的计算样式,并检查元素值?
使用Tomalaks回答我为webkit制作了这个可爱的脚本
window.getComputedStyle(document.getElementById("frameId"), null).getPropertyValue("height")
Run Code Online (Sandbox Code Playgroud)
要么
window.getComputedStyle(document.getElementById("frameId"), null).getPropertyCSSValue("height").cssText
Run Code Online (Sandbox Code Playgroud)
结果150px
相同
$('#frameId').height();
Run Code Online (Sandbox Code Playgroud)
所以我让他们在头部添加一个'brshtml'的id-也许它会帮助我更容易地选择元素.Webkit检查现在向我显示html #brshtml但我无法使用它来选择它getelementbyid