任何人都可以帮我编写脚本..或获得价值的方法
height : 1196px;
width: 284px;
从计算的样式表(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>
我最接近的是这个
$('#frameId').context.lastChild.currentStyle
这给了我HTML元素上的实际样式,它是“自动”的,这是真的,因为那是在iframed文档中设置的。
如何获得所有浏览器用于计算滚动条和检查元素值的计算样式?
使用Tomalaks的答案,我想到了这个可爱的Webkit脚本片段
window.getComputedStyle(document.getElementById("frameId"), null).getPropertyValue("height")
要么
window.getComputedStyle(document.getElementById("frameId"), null).getPropertyCSSValue("height").cssText
结果150px
相同
$('#frameId').height();
因此,我让他们在头上添加了一个ID“ brshtml”,也许这将有助于我更轻松地选择元素。Webkit检查显示现在是html#brshtml,但是我无法使用进行选择getelementbyid
慕桂英3389331