使用Javascript打印iFrame内容 [英] Print iFrame content using Javascript

查看:107
本文介绍了使用Javascript打印iFrame内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用JavaScript打印iFrame内容。我已经尝试过,但是它只能在Chrome中使用。

  var iframe = document.getElementById(iframeID)。contentWindow; 
iframe.focus();
iframe.print();

这不适用于Mozilla Firefox。



在页面上的iFrame中显示PDF。

解决方案

.contentWindow.print() ; 为我工作。

我在fancybox的iframe中打开了PDF,然后调用 .contentWindow.print ();


尽管它在一些较旧的浏览器中不受支持。


I want to print iFrame content using javascript. I've tried to following but it only works in Chrome.

window.frames[frameid].print();

and

var iframe = document.getElementById("iframeID").contentWindow;
iframe.focus();
iframe.print();

It is not working on Mozilla Firefox.

I'm showing PDF in iFrame on a page.

解决方案

.contentWindow.print(); worked for me.

I've opened the PDF in iframe of fancybox and then called .contentWindow.print();.

Though it's not supported in some older browsers.

这篇关于使用Javascript打印iFrame内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆