2014-09-05 76 views

回答

2

這就是:

你的iframe:

<iframe id="printf" name="printf"></iframe> 

印刷:

window.frames["printf"].focus(); 
window.frames["printf"].print(); 

BTW,嘗試以更好的方式下一次(發佈代碼可以幫助)來解釋你的問題=)

參考Javascript Print iframe contents only

編輯:

作爲OP說沒有工作,我指的是測試頁鏈接在參考:

Print an iframe

你也可以試試這個功能(參考文獻相同,不同的海報):

//id is the id of the iframe 
function printFrame(id) { 
      var frm = document.getElementById(id).contentWindow; 
      frm.focus();// focus on contentWindow is needed on some ie versions 
      frm.print(); 
      return false; 
} 
+0

我都準備好了嘗試,但它並沒有幹活需要另一種解決方案 – 2014-09-05 10:16:16