Media-specific stylesheets

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Media-specific stylesheets

Post by uberpolak »

I'm trying to get a separate stylesheet for printing, but the print preview is making it look like no sheet is loaded at all.

Here is my style markup in the .htm file:

Code: Select all

<link rel="stylesheet" type="text/css" href="styles/pf.css" media="print" title="Printer Friendly" />
<link rel="stylesheet" type="text/css" href="styles/green.css" media="screen" title="Standard Style" />
<link rel="alternate stylesheet" type="text/css" href="styles/greenl.css" media="screen" title="Large Print" />
<link rel="alternate stylesheet" type="text/css" href="styles/bw.css" media="screen" title="Black and White" />
<link rel="alternate stylesheet" type="text/css" href="styles/bwl.css" media="screen" title="Large Print Black and White" />
Yes, I have to have all those style options, the client requires all those versions of each page, unfortunately. Can anyone see what's wrong with this? I can't figure it out. The file pf.css itself is fine, when I run it as the screen stylesheet it gets picked up and works just the way I want it to.

Thanks.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

I am unable to find any errors.

Do you have a test URL I can check to see if I have the same problem?
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

Sorry, the site is still just being developed locally, it's not online yet. Thanks for offering, though.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

Update:

I've (sort of) solved the problem, and in case anyone wanted to know how to do that, I'll post it.

It turned out the problem was that alternate stylesheets make Internet Explorer (even more) moronic. It messed up the print stylesheet whenever more than one stylesheet had been activated, not necessarily at the same time, it started ignoring the print sheet. I still don't know why.

I worked around this by using PHP Session variables to have only one stylesheet loaded at a time, based on a select box the user always has access to. They can still change it, but now they have to reload the page every time they want to change styles. The upside is, the damn thing works.
Post Reply