【问题标题】:Print all div content with jquery printElement使用 jquery printElement 打印所有 div 内容
【发布时间】:2011-06-23 09:05:08
【问题描述】:

我正在尝试使用printElement 插件打印我的 div 内容。 div 有很多文本,所以有一个滚动条。问题是插件只打印实际在屏幕上的部分文本。如何打印所有文本?

编辑:

我需要一个解决方案,该解决方案将使用外部 css 中的样式打印此 div。

【问题讨论】:

    标签: jquery printing


    【解决方案1】:

    https://github.com/jasonday/printThis

    可使用其他 css 文件和其他选项进行配置。

    【讨论】:

    • 我正在使用您的插件进行打印。我有一个特殊要求。我确实在屏幕上看到了一个表格,单元格之间没有边框。但是,当我打印它时,我想将边框应用于打印在纸上的表格。我看到有一个加载外部 css 文件的选项,但是如何将该样式应用于表格元素而不影响屏幕上显示的样式(屏幕上没有边框)。
    • @Anand - 您需要对您的普通样式表使用打印媒体查询。 '@media print { ... }' 在方括号内添加 CSS 以仅对打印视图影响页面上的元素。
    【解决方案2】:
    <div class="printclass">Print</div>
      <div id="mydivid">
            Your content goes here
      </div>
    </div>
    
    <script type="text/javascript">
    $(function(){
        $( ".printclass" )
        .attr( "href", "javascript:void(0)")
        .click(function(){
        // Print the DIV.
        $( "#mydivid" ).print();         
        // Cancel click event.
        return( false );
        });
    
    });
    </script>
    

    【讨论】:

    • Uncaught TypeError: $(...).print is not a function.
    【解决方案3】:

    【讨论】:

    • 它没有。它还存在浏览器兼容性问题(IE9 已确认)。
    • 试试我的插件 - github.com/jasonday/printThis - 适用于外部 css 文件
    • Jason,这如何处理外部 css 文件?我似乎在任何地方都找不到有关您插件的任何文档。
    猜你喜欢
    • 1970-01-01
    • 2016-02-17
    • 2013-07-19
    • 1970-01-01
    • 2020-03-24
    • 2015-09-28
    • 1970-01-01
    • 1970-01-01
    • 2011-01-16
    相关资源
    最近更新 更多