跳出Docusign中的Iframe

3
我正在使用Iframes来呈现嵌入的Docusign文档。我已经成功地在Iframe中签署了文档,并在签署后重定向到指定的URL。
但是,重定向的URL显示在Iframe内部。我需要打破Iframe并显示在父页面中。
我尝试了以下代码片段,但都没有成功。
1) 在iframe标记中使用th:target="_parent"
2) if (top !== self) top.location.href = self.location.href;

请发布您的HTML代码,以展示您如何使用iFrame。 - Praveen Reddy
有关此事有任何更新吗?你的解决方案是什么? - Anthony
1个回答

0

我已经找到了解决方案。我只需要在Iframe中捕获Docusign重定向并将其隐藏即可。

 <iframe id ="docusignFrame" name="docusignFrame" th:src="${docusignURL}" width="100%" height="900" onLoad="(this.contentWindow.location != '' ? DocusignCompleted(this.contentWindow.location) : void(0));">
</iframe>
<script>
function DocusignCompleted(url) {
                $("#docusignFrame").hide();}
</script>

1
你的代码出现了异常 "Uncaught DOMException: Blocked a frame with origin "http://localhost:xxxx" from accessing a cross-origin frame. at HTMLIFrameElement.onload (http://localhost:xxxx/abc) "。 - JB's
我知道你的评论已经有些年头了@JB,但发生这种情况的原因是因为你的浏览器安全设置。如果你要跨域,你需要使用Window.postmessage(),而且只有在你控制两个域名时才有效。https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage - Josh Maag

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接