Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Issue

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
I have two DIV's on a page. Initially one (screenView) is in view and the other(printView) is hidden.

<DIV ID=&quot;screenView&quot; STYLE=&quot;display: block;&quot;></DIV>
<DIV ID=&quot;printView&quot; STYLE=&quot;display: none;&quot;></DIV>

I call a JavaScript function on load which sets the innerHTML of the two DIVS.

However, when the user chooses to print the page, I want the printView DIV to print. I have tried using style sheets as follows to accomplish this. I have the following in my head section:

<STYLE MEDIA=&quot;print&quot;>
/* hide the Screen view of the statement */
#screenView {display: none;}
/* display the print version of the statement */
#printView {display: block;}
</STYLE>

Do I need to do any more?? the screenView DIV is being printed when i try to print the page.

I know that I could use JavaScript to manually hide one DIV and show the other but I would like to use style sheets. Mise Le Meas,

Mighty :)
 
Managed to get this working using the following:

<STYLE>

@media print {
#screenView {display: none;}
#printView {display: block;}
}

@media screen {
#screenView {display: block;}
#printView {display: none;}
}
</STYLE> Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top