【问题标题】:Print Chart within <div> tag在 <div> 标签内打印图表
【发布时间】:2013-11-27 00:22:25
【问题描述】:

我正在尝试从 Div 标签打印内容,我有一个网格和一个图表,但它只打印网格,图表是空白的,这是我正在使用的代码:

<input id="btnprint" type="button" onclick="PrintDiv()" value="Print" /></center>

<script type="text/javascript">

    function PrintDiv() {
        var divToPrint = document.getElementById('Content');
        var popupWin = window.open('', '_blank', 'width=1400,height=800,location=no,left=200px');
        popupWin.document.open();
        popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
        popupWin.document.close();
    }
</script>

【问题讨论】:

  • 在firebug中调试,查看divToPrint.innerHTML的值。

标签: c# javascript asp.net printing charts


【解决方案1】:

您可以省略 onload 函数。为我工作。可能您的 ID 拼写不正确。

【讨论】:

  • 我按照你的建议做了,但它一直只显示网格,ID 是正确的,因为网格正在显示但图表没有,还有其他建议吗?
【解决方案2】:

我将它添加到应用设置中的 web.config 中:

<add key="ChartImageHandler" ...deleteAfterServicing=false;"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-06
    • 2018-11-08
    • 1970-01-01
    • 2018-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    相关资源
    最近更新 更多