2

我试图获取内容窗口高度以将 iframe 高度设置为角度 5,但我无法做到这一点,因为我在我的 src 标记中使用了不同的域 url。我得到了“因为 cors 而被阻止”之类的异常。

HTML:

 <iframe id="appIframe" src="http://docstation-st1.dvllb.travp.net/DocStation" (load)="resizeIframe($event)"  scrolling="no" frameborder="0"   ></iframe>

主页组件.ts

resizeIframe(obj) {
 var height = obj.target.contentDocument.innerheight;
......
   }

例外:

无法从“HTMLIFrameElement”读取“contentDocument”属性:阻止具有源“ http://OtherDomain/home.html ”的框架访问跨域框架

试过:

我在 iframe-resizer 下面试过但没有运气

https://github.com/davidjbradshaw/iframe-resizer/issues/478

https://github.com/davidjbradshaw/iframe-resizer

有人可以帮我解决这个问题。

4

0 回答 0