简体   繁体   English

JavaScript 中的 Window.print()

[英]Window.print() in JavaScript

I have a question..I need to add an image when a push on the print button...For example of the top of the page I want to insert an image: Print button:我有一个问题..我需要在按下打印按钮时添加图像...例如我想插入图像的页面顶部:打印按钮:

  <li>
     <a id="myLink" href="#" onclick="window.print();return false;">Print</a>
  </li>

The print css:打印css:

#social-bar,#footer-copyright,#modal-reported,#modal-voted,#block-  user-container,#thevideoplayer
  {
display:none;
  }

Now,how I can to add the logo of company on the top?Help please现在,我怎样才能在顶部添加公司的标志? 请帮助

Add image in page.在页面中添加图像。 hide for screen and show for print.隐藏屏幕和显示打印。

@media print {
      .printlogo{ // add printlogo as class for logo image
        display: block;
     }

}

@media screen{
    .printlogo{
        display: none;
     }

}

在您的 print.css 中,确保徽标容器具有display: block或以其他方式可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM