我有一个页面按钮和IFRAME。在IFRAME中,我正在动态加载来自不同域的PDF文件。无法打印在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全文
var iframe = document.querySelector("#unofficialtranscript");
iframe.focus();
iframe.contentWindow.print();
任何想法,我怎么能打印的被装载到这是对其他域的iframe的文件。
我看到很多使用Postmessage API从主页面发送消息到IFRAME的示例,但我的情况不同,需要打印该文件。我不知道该怎么做 – 2014-10-10 14:52:36