2

ユーザー入力テキストボックスを印刷する方法。現在の jsfiddle では、デモを添付しました。Windowsポップアップを使用して、現在の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;
    }
4

0 に答える 0