user1119130
user1119130

Reputation:

my JavaScript print code work but not getting with css

code is hear

var d=new Date();
    window.frames["print_frame"].document.body.innerHTML = '<HTML>\n<head>\n<title>CLS -' + d.getTime() +'</title>\n<link href="<?php echo JURI::base();?>templates/cls/css/style.css" rel="stylesheet" type="text/css"  />\n</head>\n<body>' + document.getElementById('result_content').innerHTML + "</body>\n</HTML>" ;
    window.frames["print_frame"].window.focus();
    setTimeout('window.frames["print_frame"].window.print()',300);

this code is work fine but when it is print then not print with css style...

Upvotes: 0

Views: 714

Answers (2)

Karishma Anand
Karishma Anand

Reputation: 3

Mine also print not working with css.
below is my code:

window.frames["print_frame"].document.body.innerHTML = '<HTML>\n<head>\n<title></title>\n<link href="style.css" media="print" rel="stylesheet" type="text/css"/>\n</head>\n<body>' + document.getElementById(divId).innerHTML + "</body>\n</HTML>";
window.frames["print_frame"].window.focus();
window.frames["print_frame"].window.print();

Upvotes: 0

matpol
matpol

Reputation: 3074

you do not have a print style sheet e.g.

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

Upvotes: 2

Related Questions