動的 div クラスがあります。div 内の要素は、バックエンドの ajax Web サービス リクエストによって動的に設定されます。:-
<div class="hidden">
<asp:Button ID="Button1" runat="server"
Height="23px" style="margin-top: 0px" Width="69px" text="Print" OnClientClick="PrintElem('#hidden'); return false;"/>
</div>
この div クラス内で、動的に入力される要素のリスト。この div クラス内で印刷ボタンを使用して、すべての要素を印刷しようとしています。
function PrintElem(elem) {
Popup($(elem).html());
}
function Popup(data) {
var mywindow = window.open('', '.hidden', 'height=400,width=600');
mywindow.document.write('<html><head><title>Pharmacy List</title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
return true;
}
*これは、IE を除くすべての Web ブラウザーでうまく機能します。*