CSS Print Media Type

  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

How does one, via JavaScript, determine the media type (whether it's print, screen, projector, etc)?

document.media doesn't seem to be working, though I've found a reference to using if(document.media == "print"){ ... }. Maybe it's not working for me for the same reason the other CSS stuff isn't (http://www.ozzu.com/website-design-forum/css-visibility-property-t29666.html)...

Who knows... but it's driving me crazy.

I need to have a specific JavaScript function NOT run if the CSS media type is print, but run in all other cases... I've been working on it for a few hours now, to no avail.. any ideas?

thanks
.c
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

If you take a look at the styleswitcher code at alistapart and see how they determine the active style sheet in the function getActiveStyleSheet() you'll see how they return the title attribute of the active style sheet. I think you could use a similar approach to grab the media attribute.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 58 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.