I have the following code to load a new stylesheet to print a lightbox dialog:
$styleUrl = '../Content/styles/icis.dashboard.colorbox.print.css';
if (document.createStyleSheet) {
document.createStyleSheet($styleUrl);
}
else {
$('head').append('<link rel="stylesheet" type="text/css" href="../Content/styles/icis.dashboard.colorbox.print.css" media="print">');
}
How do i restrict the media type to print in the IE specif开发者_如何学Pythonic code?
This, I believe, will work:
if (document.createStyleSheet) {
var ieStyleSheet = document.createStyleSheet($styleUrl);
ieStyleSheet.media = "print";
}
Add onbeforeprint to your body tag:
<body onbeforeprint="loadPrintCSS()">
And the JavaScript/jQuery function:
function loadPrintCSS() {
$('head').append('<link rel="stylesheet" type="text/css" href="windows-firefox.css" media="print">');
}
This is IE specific, but that was what you asked for.
精彩评论