检查当用户选择使用javascript打印 [英] Check for when a user has selected to print using javascript

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

问题描述

当用户选择文件>打印上的浏览器,如Firefox或Internet Explorer或链接的点击运行下面的JavaScript

When a user chooses "File > Print" on a browser such as Firefox or Internet Explorer, or clicks on a link that runs the below javascript

window.print();

有没有一种方法,以有条件地检查这种模式,并禁止一些JavaScript。

Is there a way to conditionally check for this mode and disable SOME javascript.

我试图做到这一点,因为我有一个插件,为圆角边框,甚至在打印特定的样式表,我不能覆盖这些造型自己的自定义标记补充说,我不想边界打印输出时出现该页面。

I am trying to do this because I have a plugin that adds in its own custom markup for rounded borders and even in a print specific stylesheet I can not override the styling for these, I dont want the borders to appear when printing out the page.

编辑:无关的插件有通过JavaScript做样式更改用于创建一个标签式的用户界面和我已经做了打印特定的CSS覆盖的造型,当我用它工作正常Firefox的Web开发工具栏> CSS>显示由媒体类型CSS>打印..但是,当我把它打印出来这是行不通的,JavaScript的接管和改变造型..如果我禁用javascript完全那么明显的印刷工作正常试。

Unrelated to the plugin there are style changes done via javascript that is used to create a tabbed user interface and I have done print specific CSS to override the styling and it works fine when I use the Firefox web developer toolbar > CSS > Display CSS by Media type > Print.. but when I print it out it doesn't work, the javascript takes over and changes the styling.. if I disable javascript completely then the printing obviously works fine again.

感谢

推荐答案

您可以这样做:

window.old_print=window.print
window.print=function() {
    alert('doing things');
    window.old_print();
}

但这只会搭上调用的print()从页面内的JavaScript。

but this will only catch calls to print() from inside the page javascript.

你有没有尝试把!重要具体的打印样式表?

Did you try putting !important on print-specific stylesheet?

这篇关于检查当用户选择使用javascript打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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