任何人都可以帮我编写脚本..或获得价值的方法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
3 回答

慕桂英3389331
TA贡献2036条经验 获得超8个赞
它不是jQuery,但在Firefox,Opera和Safari中,您可以 window.getComputedStyle(element)用来获取元素的计算样式,而在IE中,您可以使用 element.currentStyle。返回的对象在每种情况下都是不同的,并且我不确定使用Javascript创建的元素和样式的效果如何,但也许它们会有用。
在iframe大约150像素高,以我的外表。如果其内容高1196像素(确实,html根据屏幕快照,您似乎正在探索该节点),而这正是您想要得到的,那么您应该导航到iframe文档的DOM并将上述技术应用于该DOM。
添加回答
举报
0/150
提交
取消