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

  • 问题

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

    推测是因为跨域的问题.

    vs 给出了 如下:

    {description: "没有权限", message: "没有权限", name: "TypeError", number: -2146828218}

    2017年8月8日 7:45

答案

全部回复

  • 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.

    2017年8月9日 9:41
  • 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>

    2017年8月10日 6:57
  • 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>则是没有错误, 也没有任何响应.

    2017年8月11日 1:32
  • Hi Zhili,

    window.parent.function()不支持访问跨域domains之间IFrames的请求的,这个限制主要是因为浏览器的跨域限制。我建议你试试HTML5 postMessage.

    #javascript, iframe, security - Permission denied when tring to access a js function from parent window

    https://stackoverflow.com/questions/6094514/javascript-iframe-security-permission-denied-when-tring-to-access-a-js-funct

    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.

    2017年8月14日 2:00