1.引入js插件 <script src="js/jquery.min.js"></script>css <script src="js/fancybox.js"></script> 2.製做打印頁面 <div class="form-box" style="display: none" > <div class="print" onclick="PageSetup_Null()">打印</div> <div class="print print-back"">取消</div> <div class="form-all">要打印的內容</div> </div> 3.打印的js代碼 <script> function printk(){ $(".form-box").css("display","block"); $(".form-box").animate({scrollTop:0},0); $("body").addClass("print-on"); }; //打印方法 var HKEY_Root,HKEY_Path,HKEY_Key; HKEY_Root="HKEY_CURRENT_USER"; HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; //設置網頁打印的頁眉頁腳爲空 function PageSetup_Null(){ try { var Wsh=new ActiveXObject("WScript.Shell"); HKEY_Key="header"; Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); HKEY_Key="footer"; Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); }catch(e){} window.print(); } </script> |