javascript
  • html
  • css
  • printing
  • 2017-03-02 74 views 0 likes 
    0

    我有一個JavaScript函數打印一個按鈕調用特定的div。它的工作原理就像我想但沒有styling.The問題是當我嘗試添加div風格的功能,我的功能代碼是:Css不工作在JavaScript打印功能

    function printDiv(event) { 
    var DocumentContainer = document.getElementById("page-wrap"); 
    
        var html = '<html><head>'+ 
           '<link href="./css/style.css" rel="stylesheet" type="text/css"/>'+ 
           '</head><body style="background:#ffffff;">'+ 
           DocumentContainer.innerHTML+'</body></html>'; 
    
        var WindowObject = window.open("", "PrintWindow", 
        "width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes"); 
        WindowObject.document.writeln(html); 
        WindowObject.document.close(); 
        WindowObject.print(); 
        WindowObject.close(); 
    } 
    

    任何人都可以幫助我嗎?

    回答

    0

    使用的CSS媒體查詢

    @media print 
    

    和印刷

    應用所需的樣式
    相關問題