【发布时间】:2014-10-10 20:39:21
【问题描述】:
我有一个带有按钮和 IFRAME 的页面。在 IFRAME 中,我正在动态加载来自不同域的 PDF 文件。
当我尝试使用按钮操作打印文件时,出现以下错误。
Uncaught SecurityError: Blocked a frame with origin "http://localhost:8080" from accessing a frame with origin "http://www.cplusplus.com". Protocols, domains, and ports must match.
如果我从本地系统加载 pdf 文件,我将打印它。
我使用以下代码打印 iframe Pdf
var iframe = document.querySelector("#unofficialtranscript");
iframe.focus();
iframe.contentWindow.print();
知道如何打印加载到另一个域上的 iframe 中的文件。
【问题讨论】:
标签: javascript iframe