これを機能させるのに問題があります。チャート(Highchartsから)を持つ複雑なHTMLページがあり、チャートだけを印刷しようとすると、チャートとすべての要素が表示されるように設定されたページが印刷されます:なし。これはハイチャートのモジュールです。
print: function () {
// win.print();
var chart = this,
container = chart.container,
origDisplay = [],
origParent = container.parentNode,
body = doc.body,
childNodes = body.childNodes;
if (chart.isPrinting) { // block the button while in printing mode
return;
}
chart.isPrinting = true;
// hide all body content
each(childNodes, function (node, i) {
if (node.nodeType === 1) {
origDisplay[i] = node.style.display;
node.style.display = 'none';
}
});
// pull out the chart
body.appendChild(container);
// print
win.focus(); // #1510
win.print();
// allow the browser to prepare before reverting
setTimeout(function () {
// put the chart back in
origParent.appendChild(container);
// restore all body content
each(childNodes, function (node, i) {
if (node.nodeType === 1) {
node.style.display = origDisplay[i];
}
});
chart.isPrinting = false;
}, 1000);
},
なぜこれが機能しないのかわかりません。ここに私のページのソースコードへのリンクがあります。
ありがとう!