473,411 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Figuring out media?

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
Jul 23 '05 #1
2 1249
Roberto Leibman wrote:
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 )?

<snip> ... the moment javascript hides stuff it
stays hidden ... .
Hence the !important in the print style sheet.

<snip> ... 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.
Jul 23 '05 #2

Just disable js for that page alone and only for printing, when done,
enable it right back.

Danny

On Tue, 21 Jun 2005 16:05:57 -0700, Roberto Leibman <ro*****@guessme.com>
wrote:
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


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alun | last post by:
I am trying to use the import method of attaching stlyesheets but I'm getting strange results. this is the code I'm using... <head> <title>CSS Example</title> <meta http-equiv="Content-Type"...
1
by: Garmt de Vries | last post by:
For a long time, I've used CSS to style my webpages, but only for media "screen" and "print". Now I've started looking into styling them for other media like "projection" and "handheld". I'd be...
11
by: Wolfgang Meier | last post by:
Hi, I really hope I'm not hitting a frequently asked question here, because I think almost every author must have made that decision. Anyway, here goes: Would it be better to write one global...
2
by: Sandman | last post by:
Ok, so I'm the author of a pretty big CMS system (big as in huge, not market-share big) and I've been thinking about a problem for a few weeks here on media management. The CMS accomodates both...
4
by: subeen | last post by:
Hi, I am trying to parse a rss similar to the one found here (in example) http://www.feedforall.com/mediarss.htm <!-- Snipped for Brevity --> <item> <title>FeedForAll's Show Tunes and...
0
by: Konrad | last post by:
Hi everyone. I've got problem with converting xml file to xsd schema. The Xml file looks like: <?xml version="1.0" encoding="iso-8859-2"?> <rss version="2.0"...
0
by: kplazinski | last post by:
Hi everyone. I've got problem with converting xml file to xsd schema. The Xml file looks like: <?xml version="1.0" encoding="iso-8859-2"?> <rss version="2.0"...
0
by: kplazinski | last post by:
Hi everyone. I've got problem with converting xml file to xsd schema. The Xml file looks like: <?xml version="1.0" encoding="iso-8859-2"?> <rss version="2.0"...
3
by: hurricane_number_one | last post by:
I want to be able to play/pause/next/back the tracks in whatever media player app is running. So if iTunes is running, it will receive those commands, if Windows Media Player is, it will receive...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.