2014-02-06 74 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 :) –