2013-05-21 78 views
0

我面临打印iframe内容的问题。onclick打印iframe内的内容

这是在iframe外锚标记:

<a href=”#” onclick='window.print()' >Print</a> 

,这里是我的iframe

<iframe name="newtest" src="https:xyz.com" ></iframe> 

我要打印的是锚标记的点击的iframe是外内页iframe

+0

检查,这可能帮助你的http: //stackoverflow.com/questions/6906047/printing-iframe-content-with-jquery –

回答

2
<iframe src="" id="iframeid"></iframe> 

document.getElementById("iframeid").contentWindow.print(); 

如果您尝试打印远程站点,则无法以任何方式执行此操作。

如果你是http://yoursite.org和iframe是<iframe src="http://google.com">你不能做到这一点,网站域名必须匹配

代替如果页面<iframe src="page.htm">本地页面,将工作

+0

这是行不通的 – supersaiyan

+0

编辑答案... – 2013-05-21 05:32:16

+0

但我要打印此 – supersaiyan