如何在HTML/JAVASCRIPT中一次打印多个页面 [英] How to print multiple pages at a time in HTML/JAVASCRIPT

查看:1371
本文介绍了如何在HTML/JAVASCRIPT中一次打印多个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在HTML/JAVASCRIPT中一次打印多个页面?

我有一系列网页,并且打印按钮位于最后一页.
所有页面都捕获用户数据,当用户到达最后一页时,我们应该打印所有页面.

注意:打印"按钮位于最后一页.

我怎么能达到相同的目的呢?

请帮助我!!!

问候
Roopa

How to print multiple pages at a time in HTML/JAVASCRIPT?

I have series of web pages and print button is placed at last page.
all the pages captures the user data, when user reaches last page we supposed to print all pages.

Note : print button is placed at the last page.

How can i achieve the same.

Kindly help me out !!!

Regards
Roopa

推荐答案

嘿,鲁帕,

不确切知道您的情况,所以生病后请发表一些简短的想法:

最简单的方法是,用后端(例如:asp,php等)捕获所有页面的输出,并将其存储在会话中.然后,在最后一页上,打印"按钮将加载一个单独的页面(弹出窗口,_blank),在这里您仅从会话中输出所有缓存的html(仅课程内容).

另一种方法是,如果您要使用ajax加载页面(因此,没有真正的页面重新加载),则可以将每个带有JavaScript钩子(主体加载)的步骤(页面)存储在全局javascript变量(数组)中.最后,打印"按钮将所有内容从javascript数组一个接一个地加载到正文中(或在新窗口中).

请注意,使用html确实不可能以一种很好的方式将其分隔为实际页面...这将由浏览器决定何时放置分页符.我通过将html导出为pdf来解决了类似的情况,然后您可以更轻松地处理分页符,但是我想它太过分了:).

希望以上任何想法都对您有所帮助.

最好,

博扬
Hey Roopa,

Dont know exactly your case, so ill just post quick thoughts:

The easiest would be if you catch the output of all the pages with your backend (re: asp, php, whatever it is), and store it in the session. At the last page, the print button would then load a separate page (popup, _blank), where you just output all the cached html from the sesssion (only the contents ofcourse).

Another way would be if you are loading your pages with ajax (so, no real page reload), you can store each step (page) with a javascript hook (body onload) in a global javascript variable (array). At the end the print button loads in the body (or in a new windows) all the content one after the other from the javascript array.

Note that separating it to real pages is not really possible in a good way with html... it would be a browser decision when to put a page break. I solved a similar scenario by exporting the html to pdf, then you can handle page breaks much easier, but i guess its going too far :).

Hope any ofthe thoughts above help.

Best,

Boyan


这篇关于如何在HTML/JAVASCRIPT中一次打印多个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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