views:

54

answers:

3

Hi

I am trying to load my print.css but it does not seem to be loading. it work Fine in FF and Safari but the problem is only in IE.

I have the regular external css for the page inbetween the head tags

And when the user click on the print link . it loads the print css .

<div class="linkPrint">
<a target="_blank" href="?format=print">Print</a>
</div>


var format = getUrlParam('format');
if (format == 'print') {
    $('head').append('<link href="/theme/print.css" rel="stylesheet" type="text/css" />');
} 

But,in IE it load the standard css instead of the print.css.

How do can this be fixed for IE6?

Thanks

+7  A: 

You can have the print CSS and your screen CSS both loaded at the same time on the page without them interfering with each other - you need to specify the media attribute on the link tag:

<link href="/theme/print.css" rel="stylesheet" type="text/css" media="print" />
<link href="/theme/screen.css" rel="stylesheet" type="text/css" media="screen" />

No need to go through the javascript trickery.

As for IE6 - it does support this, as can be seen on the comparison list on this page.

Oded
Thanks yes that one way. But I cant use that in this case. How can this work in IE6 using the above javascript, it work fine in FF and Safari and Crome, but fails in IE6
How come you can't use this, but can use a javascript hack?
Oded
A: 

Try removing the <link> to the other css file when you append the print.css

Scobal
A: 

try with document.write,

document.write('<link href="/theme/print.css" rel="stylesheet" type="text/css" />');
eos87