使用Javascript打印多个页面 [英] Printing multiple pages with Javascript

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

问题描述

我有一个网站,用户点击阅读更多按钮,以便他们可以查看页面上的其他信息。我很好奇我是如何做到的,以便用户不必单独打印每个页面。我希望能够做到这一点,以便我可以有一个打印相关页面的脚本。我有人可以帮助我,并指出我正确的方向,我将不胜感激。我需要此功能才能在所有浏览器中使用。

I have a website where users click a read more button so that they can view the rest of the information on the page. I am curious how I could make it so that users do not have to print each page seperately. I would like to be able to make it so that I could have a script that print's related pages. I'f anyone could help me out and point me in the right direction it would be greatly appreciated. I need this functionality to work in all browsers.

谢谢

推荐答案

你需要做的是一个利用媒体风格的样式表。它基本上就像有两个单独的样式表;一个用于打印,一个用于查看。为了保证带宽保守,请将 printarea 设为空,直到发出请求为止。在请求事件中填写 printarea ,并打印完整版。我建议你研究一下jQuery及其加载和ajax请求。

What you will need to pull this off is a stylesheet that utilizes media styles. It is basically like having two seperate stylesheets; one for printing and one for viewing. In order to be bandwidth conservative leave the printarea empty until the request is made. On the request event fill in the printarea with the whole print you with to do. I would suggest you look into jQuery and their load and ajax requests for this.

@media screen
    {
    #screenarea
        {
        display: block;
        }
    #printarea
        {
        display: none;
        }
    }
@media print
    {
    #screenarea
        {
        display: none;
        }
    #printarea
        {
        display: block;
        }
    }

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

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