现在的位置: 首页 > 综合 > 正文

ie window.print(); 打印总结

2018年01月27日 ⁄ 综合 ⁄ 共 1252字 ⁄ 字号 评论关闭

一、

     

<!--media=print 这个属性可以在打印时有效-->
<style media="print">
    .Noprint{display:none;}
    .PageNext{page-break-after: always;}
</style>

二、添加边框的颜色(打印时)

      

	/*打印边框颜色*/
	.tabp {border-color: #000000;border-collapse:collapse;text-align: center;}
	table tr{font-size:12px;}
	.highPatient table tr th{line-height:15px;}
	.highPatient table tr td{line-height: 10px;}
	.push table tr th{line-height:20px;}
	.push table tr td{line-height: 30px;}

三、设置网页打印的页眉页脚为空(包含url地址)

     

   var hkey_root,hkey_path,hkey_key;
	hkey_root="HKEY_CURRENT_USER";
	hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
      	//设置网页打印的页眉页脚为空
	function PageSetup(){
		try{
			var RegWsh = new ActiveXObject("WScript.Shell");
			hkey_key="header" ;
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
           	 hkey_key="footer";
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
         		hkey_key="margin_bottom";
       		RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
       			hkey_key="margin_left";
       		RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
       			hkey_key="margin_right";
       		RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
       			hkey_key="margin_top";
       		RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
       		return true;
		}catch(e){
			alert(e.message);
			return false;
		

四、window.print();  打印

五、如果出现左右文字打印不完整,就设置width: 95%

六、如果出现   "automation服务器不能创建对象" ,就设置一下浏览器

      安全--->internet--->自定义级别--->对未标记为可安全执行脚本的ActiveX 控件初始化并执行脚本。选择 提示

抱歉!评论已关闭.