开发者

Special print style for different print buttons with after-print removal

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜