【问题标题】:How to print the pop up window content with the main content如何打印带有主要内容的弹出窗口内容
【发布时间】:2016-01-27 07:15:44
【问题描述】:

我想打印我的页面内容。但这包含一个弹出窗口。我需要在我的主页中显示弹出窗口内容,其中包含一个按钮名称详细信息。当我单击按钮时,将显示一个弹出窗口。

当我点击我的打印按钮时。只显示主要内容。弹出显示窗口的特定字段为空白(详细信息按钮)

我正在使用window.print();

打印按钮=> 'onclick="printpage()"'

功能

function printpage()
{
    $('#hiddendiv').html($('#view_popup_descriptive_index').html()); 
    $('#hiddendiv').show();
    window.print();
    $('#hiddendiv').hide();
}

任何显示弹出内容的方法。

【问题讨论】:

  • 你能添加小提琴或详细说明你的问题
  • 再次,同样的问题。您的主页上有弹出内容吗?除非在屏幕上可见,否则您无法使用主页打印弹出内容
  • Rose,请添加一个 sn-p 或 fiddle 或 bin,以便我们更容易理解您的愿望..
  • Mosh Feu,我必须打印一个包含数据的表结构..该表包含学生详细信息..其中一个列名为 Details.该按钮显示在每个学生身上。单击按钮时显示包含一些描述的弹出窗口
  • 所以,当您单击“打印”按钮时,弹出窗口消失了,对吗?你用什么插件来弹出窗口?

标签: javascript jquery printing popup


【解决方案1】:

您可以尝试在打印之前将弹出窗口中的 HTML 附加到页面。

$("#print").on('click', function(){
    //find HTML
  var $popupContent = $('.popup').html();

  //console.log($popupContent); //see what you really get from the popup

  //create a div before the button and put the popup content there
  $(this).before($('<div />', {
    'class': 'created',
    'html': $popupContent
  }));

  //trigger printing
  window.print();

  //remove the dynamically created container
  $('.created').remove();
})

您可以在此处在线查看它 - https://jsfiddle.net/skip405/6dt2dhm7/

【讨论】:

  • 我需要你的帮助。请帮助我
  • @Rose,有什么问题?
猜你喜欢
  • 1970-01-01
  • 2010-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-24
  • 1970-01-01
相关资源
最近更新 更多