0
votes

I want to print the content of my page. But that contain a popup. I need to display the pop up window content in my main page contain a button name Details. When I click the button a pop up will show.

When I click my print button.Only show the main content. The particular field for the pop up displaying window is blank (Details button)

I'm using window.print();

print button=> 'onclick="printpage()"'

function

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

Any method to display the popup content.

1
can you add fiddle or elaborate you problemKunal Gadhia
Again, the same question. Do you have your popup content on the main page? You cannot print a popup content with the main page unless it is visible on screenprogrAmmar
Rose, please add a snippet or fiddle or bin so it will be easier to us to understand your wish..Mosh Feu
Mosh Feu,i have to print a table structure contain datas..The table contains students details..One of the column name is Details.that button shows on each student.When click the button display a popup that contain some descriptionrobins
so, the popup disappears when you click the 'print' button, is that correct? what plugin do you use for popups?skip405

1 Answers

1
votes

You may try appending the HTML from the popup to the page before printing.

$("#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();
})

You can see it working online here - https://jsfiddle.net/skip405/6dt2dhm7/