如何用主要内容打印弹出window内容
How to print the pop up window content with the main content
我想打印我页面的内容。但这包含一个弹出窗口。我需要在我的主页中显示弹出 window 内容,其中包含一个按钮名称详细信息。当我单击按钮时,会显示一个弹出窗口。
当我点击打印时 button.Only 显示主要内容。显示 window 的弹出窗口的特定字段为空白(详细信息按钮)
我正在使用 window.print();
打印按钮=> 'onclick="printpage()"'
函数
function printpage()
{
$('#hiddendiv').html($('#view_popup_descriptive_index').html());
$('#hiddendiv').show();
window.print();
$('#hiddendiv').hide();
}
任何显示弹出内容的方法。
您可以尝试在打印前将 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/
我想打印我页面的内容。但这包含一个弹出窗口。我需要在我的主页中显示弹出 window 内容,其中包含一个按钮名称详细信息。当我单击按钮时,会显示一个弹出窗口。
当我点击打印时 button.Only 显示主要内容。显示 window 的弹出窗口的特定字段为空白(详细信息按钮)
我正在使用 window.print();
打印按钮=> 'onclick="printpage()"'
函数
function printpage()
{
$('#hiddendiv').html($('#view_popup_descriptive_index').html());
$('#hiddendiv').show();
window.print();
$('#hiddendiv').hide();
}
任何显示弹出内容的方法。
您可以尝试在打印前将 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/