重定向到其他页面的 iFrameResizer 问题

iFrameResizer issue on redirection to other page

我将 iframe-resizer 用于跨域应用程序,Iframe 在应用程序内部加载正常,但是当我单击一个重定向到 Iframe 应用程序上的其他 URL 的按钮时,它给出了我的错误:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided () does not match the recipient window's origin ().

我已经像 https://example.com, now the home page on example.com is loading fine but when I redirect to other page which has URL like https://example.com/product/details 一样给了 Iframe 的 src 然后上面的错误来了。

我已经升级到 4.1 版本的库,问题已解决,但它仍然在控制台上显示错误。现在我面临重定向后无法在页面内获取父应用程序URI的问题。

我正在使用 document.referrer 来获得它,它在 Iframe 的主页上运行良好,但在重定向后的其他页面上运行不正常,我还面临移动设备上重定向页面的高度问题,该页面显示很长空白 space 原因是所有子页面都在选择 Iframe 主页面的高度,而不是调整高度。

这两个应用程序都托管在 IIS 上,并且在我们的控制之下。任何 help/sugesstion 将不胜感激。

我使用 window.postMessage 从父应用程序向 post 向子 iframe 应用程序发送消息,并使用 属性 event.origin 能够获取父应用程序的 URI,即在重定向发生时托管 Iframe,它将子应用程序页面作为其父级,这给出了错误的 URI。

父应用程序:

var frame = document.getElementById('wizardIframe');
frame.contentWindow.postMessage(window.location.href, '*');

子页面

 window.addEventListener('message', function (event) {
        window.iFrameResizer = {
            targetOrigin: event.origin
        }