Chrome 下有没有办法获取到iframe 的title?(其它网域)


RT 比如我在iframe#view 中加载baidu.com 然后使用$("#view").get(0).contentWindow.document.title,报错: Blocked a frame with origin " http://xxxx " from accessing a frame with origin " http://www.baidu.com ". Protocols, domains, and ports must match. TypeError: Cannot read property 'title' of undefined

同一网域下的就没问题

chrome JavaScript

kagome 11 years ago

你这段代码正常工作的前提是,你的iframe里嵌入的页面和你嵌入这段代码的页面在同一domain下。不同domain的貌似不可以。

smooth answered 11 years ago

Your Answer