1

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

1
  • What happens if you use standard DOM methods like document.createElement("link"), etc., and append that to the head? Commented Jun 25, 2010 at 21:47

3 Answers 3

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
0

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

Comments

0

try with document.write,

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.