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