我正在尝试获取iframe的(https://booking.yourdomain.com从https://www.yourdomain.com)内容,因此我可以将其设置为高度。因此,所有的内容是可见的,像这样(我把表情从here):当域名和协议匹配时获取iframe内容的高度,但子域名不是
var booking_iframe = document.querySelector('iframe');
booking_iframe.onload = function() {
booking_iframe.style.height = booking_iframe.contentWindow.document.body.offsetHeight + 'px';
}
但是,这激发了以下错误:
VM389:1 Uncaught DOMException: Blocked a frame with origin "https://www.yourdomain.com" from accessing a cross-origin frame.
at <anonymous>:1:54
域和协议匹配,但子域名没有,
有什么建议吗?
(如果你想和德调试器玩我创建了一个test.html只有在生产环境中的iframe)
CNC中
作为一种变通方法: 任何想法如何使滚动在iframe的内容上? (试过固定的高度和溢出滚动和滚动=“是”,但将无法正常工作)
域名不匹配。就同源策略和跨源限制而言,“子域”的概念并不存在。就浏览器而言,您所处理的内容与两个不匹配的域完全相同 - “https://www.yourdomain.com”vs“https://some.compreviously”。 other.site.com' – sideshowbarker
你是什么意思“启用iframe的内容滚动”?在我看来,它是默认启用的(见[jsfiddle](http://jsfiddle.net/ConnorsFan/5s4u7bz9/);在Windows,Chrome和Firefox中测试)。 – ConnorsFan
我检查问题(test.html)中的链接,你会发现它不是我的情况。 –