2014-02-06 40 views
0

我发现一些代码,以帮助内的CSS链接股利时打印

页的我打印一部分代码:

function Clickheretoprint() 
    { 
     var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
     var content_vlue = document.getElementById("print_content").innerHTML; 

     var docprint=window.open("","",disp_setting); 
     docprint.document.open(); 
     docprint.document.write('<html><head><title>JEFCO AEROMODLERS AUCTION INVOICE</title>'); 
     docprint.document.write('</head><body onLoad="self.print()"><center>');   
     docprint.document.write(content_vlue);   
     docprint.document.write('</center></body></html>'); 
     docprint.document.close(); 
     docprint.focus(); 
    } 


I have a CSS that I refer to as a link: 

<link rel="stylesheet" type="text/css" href="Styles/Compact/Style_doctype.css" title="prefered"> 

屏幕上显示的数据利用CSS中的链接,而不一个问题。

当我点击打印我的打印窗口弹出,内

<DIV</DIV> however, the CSS style is gone! 

<DIV> looks like this <div id="print_content"> 

我怎样才能弹出由功能Clickheretoprint(创建的窗口包含网页的部分)保留在指定的CSS链接?

感谢//

回答

0

为什么当你写它不添加样式表?

win.document.write('<head><link rel="stylesheet" type="text/css" href="yourStyleSheet.css"></head>'); 

win.print(); 
win.close(); 
+0

这就是答案;弹出窗口不奇迹般地继承CSS :) –