Pop Up Window with Contents of Div

I'd like to know the best way to be able to click a button called print that will pop up a new window with the contents of a div on the current page to be printed.
LVL 12
Nathan RileyFounderAsked:
Who is Participating?
 
COBOLdinosaurConnect With a Mentor Commented:
You don't really need a new window.  Just use an @media print in the stylesheet

@media print
  {
     style rules here
  }

Then set everything you don't want to print to display:none, and apply any special style you need to the div for optimum printing.

for the button you just need onclick="window.print();"

Cd&
0
 
Nathan RileyFounderAuthor Commented:
For this solution I need to have it open in a new window.
0
 
Nathan RileyFounderAuthor Commented:
Nevermind, I see what you mean now, it opens it into a print view anyways almost like a popup window.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.