print()在Opera浏览器上不起作用 [英] print() not working on opera browser

查看:165
本文介绍了print()在Opera浏览器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JavaScript在Opera浏览器中打开打印对话框. print()在所有浏览器中都可以正常工作,但在歌剧中却不起作用. 我的print()代码为

I am trying to open a print dialog box in Opera browser using javascript. The print() is working fine in all browsers but in opera it doesn't work. My print() code as,

var printContent = document.getElementById(elementId);
var windowUrl = url;
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
var printWindow = window.open(windowUrl, windowName, 'scrollbars=yes');
printWindow.document.write(printContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();

我想在Opera浏览器中打开打印对话框.谁能帮我吗?

I want to open print dialog box in Opera browser. Can anyone help me?

推荐答案

我遇到了同样的问题,这是唯一对我有效的解决方案:

I had the same problem and this was the only solution that actually worked for me:

window.addEventListener('load', function(e) { window.print(); }, false);

版本11.60
版本1185
平台Win32
Windows XP系统

Version 11.60
Build 1185
Platform Win32
System Windows XP

这篇关于print()在Opera浏览器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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