积极答复者
Word add-in 中使用了<iframe>嵌入了其他网页A, 在A中通过window.parent.function()调用Home.js中的function失败

问题
答案
-
Hi Zhili,
window.parent.function()不支持访问跨域domains之间IFrames的请求的,这个限制主要是因为浏览器的跨域限制。我建议你试试HTML5 postMessage.
#javascript, iframe, security - Permission denied when tring to access a js function from parent window
Best Regards,
Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已建议为答案 Emi ZhangMicrosoft contingent staff, Moderator 2017年8月14日 10:08
- 已标记为答案 ZhiliJiang 2018年1月17日 6:24
全部回复
-
Hello,
跨域的话,需要在清单文件AppDomain中指定域名或者网址.
我尝试在A中通过window.parent.function()调用Home.js的某个function,没有任何效果和错误,请问你是如果实现得到这个错误的呢?
Regards,
Celeste
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
Hi, thanks
我在manifest里配置了如下 :
<AppDomains>
<AppDomain>http://172.16.124.16:7088</AppDomain>
</AppDomains>这样的也试过 :
<AppDomains>
<AppDomain>http://172.16.124.16:7088/open/open-word.html</AppDomain>
</AppDomains>我在Home.html中引用方式如下 :
<iframe src="http://172.16.124.16:7088/open/open-word.html" height="300" width="300"></iframe>
-
Hi, thanks
我在manifest里配置了如下 :
<AppDomains>
<AppDomain>http://172.16.124.16:7088</AppDomain>
</AppDomains>这样的也试过 :
<AppDomains>
<AppDomain>http://172.16.124.16:7088/open/open-word.html</AppDomain>
</AppDomains>我在Home.html中引用方式如下 :
<iframe src="http://172.16.124.16:7088/open/open-word.html" height="300" width="300"></iframe>
我是这么配置的, 得到那个错误, 如果不配置 <appDomain>则是没有错误, 也没有任何响应.
-
Hi Zhili,
window.parent.function()不支持访问跨域domains之间IFrames的请求的,这个限制主要是因为浏览器的跨域限制。我建议你试试HTML5 postMessage.
#javascript, iframe, security - Permission denied when tring to access a js function from parent window
Best Regards,
Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已建议为答案 Emi ZhangMicrosoft contingent staff, Moderator 2017年8月14日 10:08
- 已标记为答案 ZhiliJiang 2018年1月17日 6:24