1
如何获得iframe中的iframe属性的JavaScript代码获取iframe中的iframe JavaScript和跨域
<div>
<iframe src="http://192.168.0.108:8092/"
name="otherDomain"
width="100%"
height="600px"
style="border: 0;"
data-auth-token="xyz"
data-auth-key="abc"
>
</div>
我与
console.log(window.frameElement.getAttribute('data-auth-token'))
试图属性如果iframe网址和浏览器的用户是相同的,我能够获取iframe属性。如果网址不同,我会收到以下错误消息。
Uncaught SecurityError: Failed to read the 'frame' property from 'Window': Blocked a frame with origin "http://192.168.0.108:8092" from accessing a frame with origin "http://localhost:8092". Protocols, domains, and ports must match.
是否有可能在JavaScript中获得跨域iframe属性。
感谢您的解释@Marco Bonelli。我想错了。 – Prasanna 2014-09-29 08:50:29