2013-05-21 76 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