zoukankan      html  css  js  c++  java
  • javascript区域打印代码

    这段代码是我从Highcharts的代码中改造出来的,非常感谢Highcharts的作者,先链上Highcharts的地址http://www.highcharts.com/,(Highcharts的统计图代码非常棒,功能超强大,大家可以试试)!

    下面附上js区域打印的代码

    /****************************************功能代码******************************/
    (function(){
    window.JPrint = {
    	print: function () {
    		var doc = document,
    		win = window,
    		container = doc.getElementById("container"),//这里就是你要打印的区域的id,也可以参数传过来,你们懂的:-)
    		origDisplay = [],
    		origParent = container.parentNode,
    		body = doc.body,
    		NONE = 'none',
    		childNodes = body.childNodes;
    		each = function (arr, fn) {
    			var i = 0,
    				len = arr.length;
    			for (; i < len; i++) {
    				if (fn.call(arr[i], arr[i], i, arr) === false) {
    					return i;
    				}
    			}
    		};
    		each(childNodes, function (node, i) {
    			if (node.nodeType === 1) {
    				origDisplay[i] = node.style.display;
    				node.style.display = NONE;
    			}
    		});
    		body.appendChild(container);
    		win.print();
    		setTimeout(function () {
    			origParent.appendChild(container);
    			each(childNodes, function (node, i) {
    				if (node.nodeType === 1) {
    					node.style.display = origDisplay[i];
    				}
    			});
    		}, 1000);
    	}
    };
    }());
    /*******************************下面是用法**********************************/
    JPrint.print();
     

     玉米串

  • 相关阅读:
    Swift扩展(Extension)
    Swift构造器(Initializer)与析构器(Deinitializer)
    Swift下标
    Swift方法
    Swift属性
    Swift类与结构体
    Swift闭包(Closure)
    python调用c++/c 共享库,开发板上编译的一些坑!
    python调用c++类方法(2)
    ubuntu 18.04 gcc g++降级4.8版
  • 原文地址:https://www.cnblogs.com/fcode/p/2306593.html
Copyright © 2011-2022 走看看