printany.js

来自「研究和开发移动道中数字传输技术的第一步工作就是认识移动信道本身的特性」· JavaScript 代码 · 共 124 行

JS
124
字号
/*----------------------------------------------------------
  -- 目的: 打印任何内容
  -- 输入: s 需要打印的内容字符串
-----------------------------------------------------------*/ 
function printany(s) {
	if (s=="") return; 
	var sTitle=document.title;
	sTitle=sTitle.split("-");
	sTitle=sTitle[0];
	win=window.open('','print','height=500,width=780,menubar=no,status=0,titlebar=0,toolbar=0,scrollbars=1');
	win.document.clear();
	win.document.write("<title>"+sTitle+"</title>");
	win.document.write('<link rel="stylesheet" type="text/css" href="../css/print.css">');
	win.document.write("<body bgcolor='white' onload="+'"'+"setTimeout('self.close()',10*1000)"+'">');
	win.document.write(s);
	win.document.write("</body>");
	win.document.close();
	win.print();
}

/*----------------------------------------------------------
  -- 目的: 构建需要打印的内容
  -- 输入: s 需要打印的内容字符串,sC 标题
-----------------------------------------------------------*/ 
function printpg(s) {
	var sTitle=document.title;
	var argv = printpg.arguments;  
	var nArg = printpg.arguments.length;  
	var sC = (nArg >1) ? argv[1] : document.title.split("-")[0];  
	sTitle='<table align="center" width="95%"><tr><td>'+ sTitle
			+'</td><td  align="right">http://'+window.location.hostname+'</td></tr>';
	sTitle+='<tr><td colspan="2"><hr size="1"></td></tr></table>' ;
	var sStr='<table align="center" width="90%" border="0" align="center">'
			 +'<tr><td>'
		 	 +s
		  	 +"</td></tr></table>";
	sStr=sTitle+'<br><P align="center"><font size="+1">'+sC+'</font></p>' + sStr;
	printany(sStr);
}

/*----------------------------------------------------------
  -- 目的:自定义打印
  -- 输入:frm 表单,s 配置参数
  -- 日期:2002-11-25
  -- 编码:Qingze Cheng  
  -- 版权:云因信息(YunYin.com)
  -- 修改:
-----------------------------------------------------------*/ 
function printc(frm,s) {
	if (s=="") return;
	var sUo=frm.action;
	//取得调用此函数的程序的地址
	sPath=window.location.pathname;
	sPathArr=sPath.split("/");
	frm.action="../print/print.cfm?sRscFile=../"+sPathArr[1]+"/"+s;
	frm.target="printset";
	var sAttr="width=500,height=440,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=1";
	newWin= window.open("","printset",sAttr);
	frm.submit();
	newWin.focus();
	frm.action=sUo;
	frm.target="_self";
}

/*----------------------------------------------------------
  -- 目的:导出数据
  -- 输入:frm 表单,s 配置参数
-----------------------------------------------------------*/ 
function expdatat(frm,s) {
	if (s=="") return;
	printc(frm,s+"&sUway=E");	
}

/*----------------------------------------------------------
  -- 目的:导出数据-详细
  -- 输入:
-----------------------------------------------------------*/ 
function expdata() {
	frmExpData.sExpData.value=ContentArea.innerHTML;
	frmExpData.submit();	
}

/*----------------------------------------------------------
  -- 目的:导出数据-详细.
  -- 输入:s 格式,sF-文件名称 
-----------------------------------------------------------*/ 
function expdoc(s,sF){
	frmExpData.sExpData.value=ContentArea.innerHTML;
	var sU=frmExpData.action;
	frmExpData.action="expdata.cfm?PopUse=1&sFormat="+s+"&sFile="+sF;
	frmExpData.submit();
	frmExpData.action=sU;
}

/*----------------------------------------------------------
  -- 目的: 发送页面内容
  -- 输入: s 类型
-----------------------------------------------------------*/ 
function send(s) {
	var argv = send.arguments;  
	var nArg = argv.length;  
	var sC=document.title.split("-")[0];
	var s = (nArg >0) ? argv[0] : "";  
	var sPg="sendinfo.cfm?";
	var sH="width=600,height=440";
	if (s=="M") {
		sPg="mailsend.cfm?iHTML=1&PopUse=1&";
		sH="width=620,height=500";
	}
	winSend = window.open(sPg+ "PopUse=1&sSubject=发送信息-"+sC, "winSend", sH+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0"); 
	winSend.focus();
}

/*----------------------------------------------------------
  -- 目的: 自定义打印
  -- 输入: s 参数
-----------------------------------------------------------*/ 
function printcdf(s) {
	if (s=="") return;
	var sAttr="width=750,height=500,toolbar=0,location=0,directories=0,status=0,menuBar=1,scrollBars=1,resizable=1";
	prWin = window.open("../print/printcd.cfm?"+s,"printWin",sAttr);
	prWin.focus();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?