Code Monkey home page Code Monkey logo

print.js's Introduction

Print.js 网页打印插件(本项目已停止维护)

print.jpg

  • 原生js,不依赖其它库
  • 可指定打印(或不打印)区域
  • 支持css样式(内联、外联、嵌入)
  • 支持input(radio/checkbox/text)、select、textarea值获取

使用方法

  1. 引入Print.js

    <script src="Print.js"></script>
    
  2. 调用方法

    Print('#Dom',{
    	noPrint:'.no-print'
    });
    
  3. 所有参数

    noPrint : String 不打印区域,默认'.no-print'
    onStart : Function 打印前回调
    onEnd  : Function 打印后回调(不区分确定/取消)
    
  4. 指定不打印区域

方法一. 添加no-print样式类

	<div class="no-print">不要打印我</div>

方法二. 自定义类名

	Print('#Dom',{noPrint:'.do-not-print-me-xxx'});
	
	<div class="do-not-print-me-xxx">不要打印我</div>

演示地址

思路

将目标区域的dom/css添加到空iframe中,打印该iframe。

注意

  1. 不支持background-color背景色打印,试试用background-image代替
  2. 低级浏览器兼容性待验证

print.js's People

Contributors

denghao123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.