window.print打印指定div
来源:互联网 发布:朗读女软件 编辑:程序博客网 时间:2024/05/17 19:58
window.print可以打印网页,但有时候我们只希望打印特定控件或内容,怎么办呢?
首先我们可以把要打印的内容放在div中,然后用下面的代码进行打印。
<html>
<head>
<script language="javascript">
function printdiv(printpage)
{
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}
</script>
<title>div print</title>
</head>
<body>
//HTML Page
//Other content you wouldn't like to print
<input name="b_print" type="button" class="ipt" onClick="printdiv('div_print');" value=" Print ">
<div id="div_print">
<h1 style="Color:Red">The Div content which you want to print</h1>
</div>
//Other content you wouldn't like to print
//Other content you wouldn't like to print
</body>
</html>
- window.print打印指定div
- window.print打印指定div
- window.print打印指定div
- window.print打印指定div
- window.print打印指定div-打印网页指定区域
- 用window.print()打印指定div里面的内容
- 用window.print()打印指定div里面的内容
- window.print打印指定div实例代码_javascript技巧
- window.print()打印指定区域
- 指定window.print 打印区域
- window.print打印指定区域。
- window.print打印指定div指定网页指定区域的方法
- window.print 打印页面指定区域
- 用window.print()函数打印网页指定区域的内容
- window.print的使用(含打印网页指定区域)
- window.print打印网页
- window.print 页面打印
- window.print分页打印
- C# system.data.sqlite使用
- 极光推送技术原理:移动无线网络长连接
- 链路层成帧方式
- Android的屏幕适配问题(Phone、Pad)
- sql server(PIVOT) 行列转换
- window.print打印指定div
- 大小写转换
- KEIL MDK Program Size 查看代码量、RAM使用情况--RO-data、RW-data、ZI-data的解释
- 深度优先搜索算法
- hibernate一对多关系映射(自身关联)
- Nginx event核心模块之process部分详解(四)
- dayOfYear
- android js html5常用颜色 速查表
- Objective-C编码规范(命名)_____2