window.print打印指定div 
首先我们可以把要打印的内容放在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实现打印特定控件或内容的更多相关文章

  1. HOW TO:使用 Visual C# .NET 打印 RichTextBox 控件的内容

    概要 本分步指南介绍了如何打印 RichTextBox 控件的内容.RichTextBox 控件没有提供任何打印 RichTextBox 内容的方法.您可以扩展 RichTextBox 类以使用 EM ...

  2. C#如何打印RichTextBox控件的内容

      本任务的内容 摘要 创建 RichTextBoxPrintCtrl 控件 测试控件 参考 概要 本分步指南介绍了如何打印 RichTextBox 控件的内容.RichTextBox 控件没有提供任 ...

  3. 读取其他软件listview控件的内容

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  4. C++ 一个程序获取另一个程序Edit控件的内容

    //一个程序获取另一个程序Edit控件的内容 //根据指定程序的标题名获取改程序窗口的句柄 HWND hWnd=::FindWindow(NULL,"zhang001"); if( ...

  5. 重新想象 Windows 8 Store Apps (3) - 控件之内容控件: ToolTip, Frame, AppBar, ContentControl, ContentPresenter; 容器控件: Border, Viewbox, Popup

    原文:重新想象 Windows 8 Store Apps (3) - 控件之内容控件: ToolTip, Frame, AppBar, ContentControl, ContentPresenter ...

  6. C#获取类名为Internet_Explorer_Server控件的内容

    为了让大家都能够使用demo,我以IE为测试对象,另外为了突出重点,所以如何获取窗口句柄我就不做演示了(不清楚的童鞋,可以去Google下哈),句柄值我使用spy++获得 大家可以下载demo(附:s ...

  7. ListView 控件与 内容

    1)由控件获取内容:ListViewItem item = Utilities.GetVisualParent<ListViewItem>(chx); if (item == null) ...

  8. js打印(控件)及多种方式

    非常好用的LODOP打印控件 Lodop打印控件简单使用方法 1.安装. 2.调用LodopFuncs.js文件. 3.增加OBJECT对象 <script language="jav ...

  9. JS打印——第三方控件打印

    LODOP 官方地址:http://www.lodop.net/ 一个很好的打印控件,可以是实现纸张设置.横打竖打.打印预览.打印维护多种功能.官网的示例非常详细.能很好支持多种浏览器的打印. 在使用 ...

随机推荐

  1. 【转】 iOS日常学习 - iOS10上关于NSPhotoLibraryUsageDescription等问题

    原文网址:http://blog.csdn.net/wang631106979/article/details/52578001 最近升级了Xcode8.0,真是很多坑啊,填完一个来另外一个,今天又遇 ...

  2. 在CentOS里使用MySQL Connector/C++

    操作系统版本:CentOS6 64位 1,安装boost库.因为MySQL Connector/C++使用了boost库,所以必须先安装boost库,我们才能使用MySQL Connector/C++ ...

  3. docker学习3-虚拟网络模式

    一.虚拟机网络模式 在理解docker网络隔离前,先看下之前虚拟机里对网络的处理,VirtualBox中有4中网络连接方式: NAT Bridged Adapter Internal Host-onl ...

  4. javaScript call 函数的用法说明

     call 方法  请参阅 应用于:Function 对象 要求 版本 5.5 调用一个对象的一个方法,以另一个对象替换当前对象. call([thisObj[,arg1[, arg2[, [,.ar ...

  5. 单例模式-ios

    #import <Foundation/Foundation.h> @interface UserContext : NSObject <NSCopying> @propert ...

  6. Js中的window.parent ,window.top,window.self ,window.openner详解

    在应用有frameset或者iframe的页面时,parent是父窗口,top是最顶级父窗口(有的窗口中套了好几层frameset或者iframe),self是当前窗口, opener是用open方法 ...

  7. 【转】PHP简单拦截器的实现

    最近在看Yii的源代码,收获了不少,这里就是从中得到的启发,而写的一个简单拦截器的实现下面看例子: <?phpclass A{    private $_e = array();       p ...

  8. centos6.5 安装iptables

    阿里云默认是没有安装iptables 安装 yum install -t iptables yum install iptables-services 检查iptables服务的状态 service ...

  9. DBA常用SQL之表空间与数据文件

    )), ) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name g ...

  10. RMAN备份与恢复之表空间

    通过以下事例来说明表空间的恢复,删除表空间内的数据文件,删除后在针对位于该表空间的表进行插入记录以及实施检查点进程 SQL> select a.tablespace_name from dba_ ...