我有一个div
.id
target_wrapper
<div id="target_warpper">
<div id="target">
///Some content here
</div>
</div>
打印页面的相应javascript函数是:
<div class="print_list">
<a href="javascript:PrintContent()">Print</a>
</div>
<script type="text/javascript">
function PrintContent()
{
var DocumentContainer = document.getElementById('target_warpper');
var WindowObject = window.open('', 'PrintWindow', 'width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes');
WindowObject.document.writeln('<!DOCTYPE html>');
WindowObject.document.writeln('<html><head><title></title>');
WindowObject.document.writeln('<link rel="stylesheet" type="text/css" href="css/print.css">');
WindowObject.document.writeln('</head><body>')
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.writeln('</body></html>');
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
</script>
但是当我点击Print
链接时,出现的页面不包含css
css/print/css
我包含的内容。
注意:当我单击打印弹出窗口的查看页面源时,它显示为空白!