Figuring out media?

R

Roberto Leibman

I haven't been able to figure this out, or find any resource for this.

I'd like to be able to know, in javascript, if the media that's rendering
is screen or print. I have no nefarious purpose here (I've often seen
people wanting to do this to prevent printing): I have a report that uses
javascript to page 20 items at a time and I want it to show all items at a
time when printing.

- I can make it more or less work on IE using onbeforeprint, but no luck
on better browsers
- When the page first renders the combination of @print and @screen styles
work good, but the moment javascript hides stuff it stays hidden (because
it's changing the element.style attribute of the rows.
- I've tried figuring it out by having an element with different styles
declared in the @print and @screen rules of the stylesheet, but I can't
make it show any difference to the javascript being executed (e.g.
changing the position of this element for print and screen, the element's
position is always what is first calculated for the screen).

Any other ideas?

Roberto
 
R

Richard Cornford

Roberto said:
I haven't been able to figure this out, or find any resource for this.

I'd like to be able to know, in javascript, if the media
that's rendering is screen or print. I have no nefarious
purpose here (I've often seen people wanting to do this
to prevent printing): I have a report that uses javascript
to page 20 items at a time and I want it to show all
items at a time when printing.

So you want to create a print media only style sheet (and !important )?

... the moment javascript hides stuff it
stays hidden ... .

Hence the !important in the print style sheet.

... element's position is always what is first
calculated for the screen).

Yes, it is unlikely that a print renderer would be executing javascript,
they don't need to be interactive.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top