针对不同打印按钮的特殊打印样式,带印后去除功能

发布于 2024-11-05 18:17:02 字数 920 浏览 0 评论 0原文

我正在开发一个页面,该页面底部有一个区域,列出了常见问题解答的分组,其中包含几个不同的选项卡级别,然后是用户可以展开/折叠的问题。我们希望提供一种方法,让用户能够很好地打印

  1. 他们已展开的问题/答案
  2. 他们选择的子组中的所有问题/答案
  3. 他们选择的主要组中的所有问题/答案
  4. 所有页面上的问题/答案

计划是有一个带有打印按钮(Javascript 未隐藏)的下拉框,该下拉框将应用一个类,当单击该类时,该类将隐藏页面上的其他内容并为我们提供我们想要的显示用户选择的选项。这一切都很容易做到,当 javascript 被禁用时,我们可以使用 #4 应用默认的打印样式作为包罗万象,这可以通过正常的打印机制触发。

问题是如何在打印完成后删除该特殊样式,以便如果用户点击浏览器的打印按钮,他们会得到他们期望的整个页面的打印内容,而不是最后选择的“特殊”打印内容看法。

我想出了一些潜在的解决方案,但我对其中任何一个都不完全满意:

  1. 我们可以用指向另一个页面的链接替换我们计划的页面打印,该页面会自行格式化而不干扰页面内容的其余部分。我不喜欢这个想法,因为它会将页面分成几部分,如果可能的话,我总是更喜欢将用户保留在页面上。
  2. 我们可以设置一个超时,当单击打印按钮时,在一段时间后将页面恢复到默认状态后删除我们的特殊类。我不喜欢这样做,因为从用户的角度来看,它会产生不可预测的行为。如果他们第一次打印的时间“太长”,他们就得不到他们想要的样式。如果他们在特殊打印后“太快”打印整个页面,则会得到奇怪的结果
  3. 我们可以使用 IE 中的打印后触发器来删除这些用户的样式,但据我所知,此解决方案只是一个选项在 IE 中,所有其他浏览器都处于冷漠状态。
  4. 我们可以做出一个一般性的假设,即用户不太可能来到该页面并进行特殊格式的打印,然后希望打印整个页面,然后就可以了。

任何人都可以想到其他解决方案吗?

I am working on a page which will have an area at the bottom listing out groupings of FAQs with a few different tab levels and then questions which can be expanded/collapsed by the user. We want to provide a way for the user to be able to nicely print

  1. Just the questions/answers they have expanded
  2. All the questions/answers in the sub-group they have selected
  3. All the questions/answers in the primary group they have selected
  4. All the questions/answers on the page

The plan is to have a drop down box with a print button (unhidden by Javascript) that would apply a class that when clicked that would hide the other content on the page and give us the display we want for the user selected option. This is all easy enough to do and we can apply a default print-style using #4 as a catch-all when javascript is disabled which can just be triggered via the normal print mechanism.

The problem is how to remove that special style when the printing is done so that if the user were to go and click the browsers print button, they get what they expect a print out of the whole page instead of the last selected "special" print view.

I have thought up a few potential solutions but I am not entirely happy with any of them:

  1. We could replace our planned in page print with a link to another page which formats itself without interfering with the rest of the page content. I don't like this idea because it breaks the page into pieces and if possible I always prefer to keep the user on the page.
  2. We could set a timeout when the print button is clicked to remove our special class after some period of time bringing the page back to a default state. I don't like this because it will produce unpredictable behavior from the user's point of view. If they take "too long" printing the first time they don't get the style they want. If they print the whole page "too quickly" after the special print they get an odd result
  3. We can use the after-print trigger in IE to remove the style for those users, but as far as I can tell this sollution is only an option in IE and leaves all the other browsers in the cold.
  4. We could make a general assumption that a user is very unlikely to come to the page and do a special formatted print followed by a desire to print the entire page and just let is go at that.

Any other solutions anyone can think of?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断肠人 2024-11-12 18:17:02

如果您使用 target="_blank",您的第一个解决方案实际上非常好。这将使用户留在页面上,但避免所有其他问题。

但是,我认为如果您使页面布局与下拉列表匹配,那么整个问题就没有意义了。换句话说,如果他们查看第 2 节第 3 小节问题 1,并且选择
“打印小节中的所有问题”,只需展开小节并打开打印对话框即可。然后您只需担心设置一个类 (noprint) 并将其应用到其他所有内容。

Your first solution is actually very good if you use target="_blank". This would keep the user on the page but avoid all the other problems.

However, I think the whole problem is moot if you make the page layout match the dropdown. In other words, if they're looking at Section 2, Subsection 3, Question 1, and they select
"print all questions in subsection", just expand the subsection and open the print dialog box. Then you only have to worry about setting a single class (noprint) and apply it to everything else.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文