开发者

How to print pdf in iframe using javascript in ie6?

开发者 https://www.devze.com 2023-03-29 05:02 出处:网络
I have displayed a pdf in iframe which is in aspx page. I am working on IE6 browser. I use the following html and javascript code.

I have displayed a pdf in iframe which is in aspx page. I am working on IE6 browser. I use the following html and javascript code.

<iframe id = "frame_singleCheque" src = "../pdf/SingleCheque.pdf" runat = "server" style ="height:400px; width: 750px; overflow:scroll;" />


function printDoc()
{
      window.frames['ctl00_contPlcHdrMasterHolder_frame_singleCheque'].focus();
      window.frames['ctl00_contPlcHdrMasterHolder_frame_singleCheque'].print();
}

<input type="button" id = "btnCPrint" value = "Print" onclick="javascript:printDoc()" />

If press print button it shows print dialog. but whenever I press print button it doesn't print any 开发者_JS百科thing. It doesn't print event a blank page. How can I print it?


Try this:

function printDoc() {
   document.getElementById('frame_singleCheque').focus(); 
   document.getElementById('frame_singleCheque').contentWindow.print();
}

EDIT: Have a look at this as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消