這段代碼是我從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();
玉米串