如何打印用户输入文本框。在当前的 jsfiddle 中,我附上了我的演示。我正在使用窗口弹出窗口在新页面中显示当前 HTML 并仅打印显示的项目。如何在当前弹出窗口中显示输入框值?
https://jsfiddle.net/amitk009/xuf29hkr/
print(){
var DocumentContainer = document.getElementById('print-area');
var strHtml = '<html><head>'+
'</head>' +
'<body style="margin-top:10px">' +
'<div class="card"><div class="card-header"><</div>' +
'<div class="card-body">' +
DocumentContainer.innerHTML +
'</div></div>' +
'</body>\n</html>';
var WindowObject = window.open('', '_blank', 'width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes');
WindowObject.document.write(strHtml);
WindowObject.document.close();
WindowObject.focus();
setTimeout(function(){
WindowObject.print();
WindowObject.close();
},1000);
return true;
}