JavaScript的打印技术体会 (转)
来源:互联网 发布:淘宝排名突然没有了 编辑:程序博客网 时间:2024/05/21 21:44
特定内容的部分打印技术
1.打印某个frame的内容(frameB)
<html>
<frameset rows="20%,*">
<frame SRC="framea.htm" name="FrameA" noresize>
<frame SRC="frameb.htm" name="FrameB" noresize>
<noframes>
<body>
</body>
</noframes>
</frameset>
</html>
frameA中添加
<input type="button" value="Print the other frame" onclick="parent.frameB.print();">
2.打印某个对象中的内容,如textbox中的内容
frameA:
<html><head>
</head>
<body>
<form name="formB" action="javascript:window.print()">
<input type="text" name="textboxb" size="12" value="Print Me">
</form>
</body></html>
frameB:
<html><head>
<script>
function printotherframe()
{
parent.FrameB.formB.textboxb.focus()
parent.FrameB.formB.submit()
}
</script>
</head><body>
<form name="formA"><input type="button" value="Print the other frame" onclick="printotherframe()">
</body></html>
3.打印非当前页
技术同上,只是在frame显示中动一点点骗人的手脚
<frameset rows="100%,*">
<frame src="controlpage.html">
<frame src="pagetoprint.html">
</frameset>
<script language="JavaScript"><!--
if (window.print)
document.write('<form><input type="button" value="Print" onClick="parent.frames[1].focus();parent.frames[1].print()"><//form>');
//--></script>
4.统一页眉页脚
<script language="Javascript"><!--
function doprint() {
//save existing user's info
var h = factory.printing.header;
var f = factory.printing.footer;
//hide the button
document.all("printbtn").style.visibility = 'hidden';
//set header and footer to blank
factory.printing.header = "";
factory.printing.footer = "";
//print page without prompt
factory.DoPrint(false);
//restore user's info
factory.printing.header = h;
factory.printing.footer = f;
//show the print button
document.all("printbtn").style.visibility = 'visible';
}
//--></script>
<body>
<br><br><br>
<object id=factory style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext codebase="ScriptX.cab#Version=5,0,4,185">
</object>
<br><br>
<div id="printbtn"><input name=idPrint type=button value="Print the letter" onclick="doprint()"></div>
</body>
5.打开新窗口并自动打印
<object id=WBControl width=0 height=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>
<script language=VBScript><!-- //
Sub VBPrint() On Error Resume Next
WBControl.ExecWB 6,1 '7,2在不少文章中都有提到,这里就不多说了。
End Sub
//--></script>
<script language=JavaScript><!-- //
if (window.print) self.print();
else if (navigator.appName.indexOf('Microsoft') !=-1) VBPrint()
setTimeout('self.close()',3000); '看代码相信大家都能明白。如果有不明白的欢迎留言
//--></script>
html中
<form>
<input type="button" value="Print Price List" onClick="window.open('pricelist.html','newwin');">
</form>
1.打印某个frame的内容(frameB)
<html>
<frameset rows="20%,*">
<frame SRC="framea.htm" name="FrameA" noresize>
<frame SRC="frameb.htm" name="FrameB" noresize>
<noframes>
<body>
</body>
</noframes>
</frameset>
</html>
frameA中添加
<input type="button" value="Print the other frame" onclick="parent.frameB.print();">
2.打印某个对象中的内容,如textbox中的内容
frameA:
<html><head>
</head>
<body>
<form name="formB" action="javascript:window.print()">
<input type="text" name="textboxb" size="12" value="Print Me">
</form>
</body></html>
frameB:
<html><head>
<script>
function printotherframe()
{
parent.FrameB.formB.textboxb.focus()
parent.FrameB.formB.submit()
}
</script>
</head><body>
<form name="formA"><input type="button" value="Print the other frame" onclick="printotherframe()">
</body></html>
3.打印非当前页
技术同上,只是在frame显示中动一点点骗人的手脚
<frameset rows="100%,*">
<frame src="controlpage.html">
<frame src="pagetoprint.html">
</frameset>
<script language="JavaScript"><!--
if (window.print)
document.write('<form><input type="button" value="Print" onClick="parent.frames[1].focus();parent.frames[1].print()"><//form>');
//--></script>
4.统一页眉页脚
<script language="Javascript"><!--
function doprint() {
//save existing user's info
var h = factory.printing.header;
var f = factory.printing.footer;
//hide the button
document.all("printbtn").style.visibility = 'hidden';
//set header and footer to blank
factory.printing.header = "";
factory.printing.footer = "";
//print page without prompt
factory.DoPrint(false);
//restore user's info
factory.printing.header = h;
factory.printing.footer = f;
//show the print button
document.all("printbtn").style.visibility = 'visible';
}
//--></script>
<body>
<br><br><br>
<object id=factory style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext codebase="ScriptX.cab#Version=5,0,4,185">
</object>
<br><br>
<div id="printbtn"><input name=idPrint type=button value="Print the letter" onclick="doprint()"></div>
</body>
5.打开新窗口并自动打印
<object id=WBControl width=0 height=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>
<script language=VBScript><!-- //
Sub VBPrint() On Error Resume Next
WBControl.ExecWB 6,1 '7,2在不少文章中都有提到,这里就不多说了。
End Sub
//--></script>
<script language=JavaScript><!-- //
if (window.print) self.print();
else if (navigator.appName.indexOf('Microsoft') !=-1) VBPrint()
setTimeout('self.close()',3000); '看代码相信大家都能明白。如果有不明白的欢迎留言
//--></script>
html中
<form>
<input type="button" value="Print Price List" onClick="window.open('pricelist.html','newwin');">
</form>
- JavaScript的打印技术体会 (转)
- [原创]JavaScript的打印技术体会
- javascript页面打印技术
- JavaScript prototype的体会
- javascript打印-打印页面设置-打印预览代码,特定内容的部分打印技术
- 技术学习的一点体会
- 对COM技术的体会
- 写技术文档的体会
- 看技术类书的体会
- 做技术三年的体会
- Javascript特定内容的部分打印技术2
- javascript 闭包的体会
- 开发web打印的一点体会
- [转]WEB 打印的相关技术分析
- [转]WEB 打印的相关技术分析
- Java的打印技术
- 关于技术和产品的一些体会
- 打印预览的javascript
- ASP开发必备:WEB打印代码大全[转贴]
- [转]WEB 打印的相关技术分析
- ASP.NET中实现Web打印的方案 (转)
- ASP.NET设置ie打印两法 (转)
- [转]ASP开发必备:WEB打印代码大全
- JavaScript的打印技术体会 (转)
- 数据结构(冒泡法)
- 3G集合
- 用 Hibernate 和 Spring 开发事务持久层
- 7款个性化的手机
- VB.NET实现DirectSound9 (7) 录音
- VB中数字转金额
- 当乞丐邂逅美女 (转)
- 世界名表(转载)