2018-08-30html
直接調用瀏覽器的打印方法ajax
一、打印按鈕瀏覽器
<a href="#" target="_self" onclick="printme()">打印</a>
二、jspost
//打印 function printme() { $.messager.confirm('確認', '確認打印?', function (r) { if (r) { document.body.innerHTML = document.getElementById('div1').innerHTML + '<br/>'; window.print(); var OrderGUID = $("#OrderGUID").val(); window.location.href = "../Details/?id=" + OrderGUID + "&Check=0"; //打印記錄 $.ajax({ type: "post", anysc: false, url: '@Url.Action("AddPrintLog")', data: { OrderGUID: OrderGUID }, success: function (da) { if (da > 0) { //alert(da.split('|')[0]); $.messager.alert('提示!', '成功!'); //location.reload(); window.location.href = "../Details/?id=" + OrderGUID + "&Check=0"; } else if (da = -1) { $.messager.alert('提示!', '添加操做記錄錯誤!'); return false; } }, }); } }); }
四、結果url