0
我有以下代碼。當我點擊'打印地圖'按鈕然後彈出窗口打開,其中有兩個按鈕'保存'和'打印'。 當我點擊'保存'按鈕,它會打開窗口來保存文件。我可以直接使用保存按鈕在窗口功能
我想要的是當我點擊'打印地圖'按鈕然後單擊保存按鈕後窗口應該打開。
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'parent', 'height=400,width=600');
mywindow.document.write('<html><head><title>my div</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.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
return true;
}
<script src="http://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://html2canvas.hertzen.com/build/html2canvas.js"></script>
<body>
<section>
<div class="main_div">
<div>
<div class="nav_div">
<input type="button" value="Print Map" onclick="PrintElem('.parent')" />
</div>
</div>
<div class="parent">
<h1>Hello All</h1>
</div>
</div>
</section>
</body>
你到目前爲止嘗試了什麼?我在這裏看到的唯一的東西是從http://stackoverflow.com/a/2255438/5703316 –
複製/粘貼請閱讀我的問題...代碼是jst的演示..我不希望預覽窗口來點擊按鈕但要保存PDF – Roma