JavaScript Area Print Code

Source: Internet
Author: User

This code is I highcharts from the code of the transformation out of, very grateful to Highcharts author, first chain highcharts address http://www.highcharts.com/, (highcharts Chart code is very good, Super powerful, we can try it!

The following code is attached to the JS area printing

?
/****************************************功能代码******************************/(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);    }};}());
/******************************* below is the usage of **********************************/jprint.print ();

JavaScript Area Print Code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.