Javascript事件处理程序打印 [英] Javascript Event Handler for Print

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

问题描述



在javascript中有一个事件,您可以在调用文件>>打印时收听吗?它是什么?还有 - 打印完成时有处理程序吗?这是什么?



或者如果有更好的方法来做这样的一些其他手段,如样式表,你怎么做?

解决方案

不同的样式表



您可以指定其他

 < link rel =stylesheettype =text / cssmedia =printhref = print.css/> 
< link rel =stylesheettype =text / cssmedia =screenhref =main.css/>

一种样式表



提到的kodecraft,您也可以使用@media块将样式放入同一个文件。

  @媒体打印{
div.box {
width:100px;
}
}

@media screen {
div.box {
width:400px;
}
}


I am trying to alter style at print-time:

Is there an event in javascript that you can listen for for when file>>print is called? What is it? Also - is there a handler for when printing is finished? What is it?

or if there is a better way to do this with some other means, such as style sheets, how do you do that?

解决方案

Different Style Sheets

You can specify a different stylesheet for printing.

<link rel="stylesheet" type="text/css" media="print" href="print.css" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />

One Style Sheet

As kodecraft mentioned, you can also put the styles into the same file by using the @media block.

@media print {
    div.box {
        width:100px;
    }
}

@media screen {
    div.box {
        width:400px;
    }
}

这篇关于Javascript事件处理程序打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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