Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

print webpage in javascript

window.print() 
Comment

document print from html javascript

export default function printDiv({divId, title}) {
  let mywindow = window.open('', 'PRINT', 'height=650,width=900,top=100,left=150');

  mywindow.document.write(`<html><head><title>${title}</title>`);
  mywindow.document.write('</head><body >');
  mywindow.document.write(document.getElementById(divId).innerHTML);
  mywindow.document.write('</body></html>');

  mywindow.document.close(); // necessary for IE >= 10
  mywindow.focus(); // necessary for IE >= 10*/

  mywindow.print();
  mywindow.close();

  return true;
}
Comment

print page in javascript

<button onclick="window.print()">print</button>
Comment

print page using js

$('.print-btn').click(function(){
  var printed_id = $(this).attr('data-id');
  if( printed_id ){
    var printed_content = $($('#' + printed_id).html());
    $('body').children().css('display', 'none');
    $('body').append(printed_content);
    window.print();
    printed_content.remove();   
    $('body').children().css('display', '');    
  }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get specific word from the string javascript 
Javascript :: disable javascript firefox 
Javascript :: how to make a button execute a javascript function 
Javascript :: window.location 
Javascript :: example of pre increment in js 
Javascript :: regex repeat n times 
Javascript :: truncate text javascript 
Javascript :: javascript generate random numbers 
Javascript :: sequelize update column type 
Javascript :: server status minecraft javascript 
Javascript :: error: cannot find module 
Javascript :: javascript remove duplicates from array 
Javascript :: get random entry from array javascript 
Javascript :: vuejs get the url params withour router 
Javascript :: javascript get array min and max 
Javascript :: chosen-select disable 
Javascript :: reversed array loop 
Javascript :: javascript date custom string format 
Javascript :: return empty new promise 
Javascript :: route component with props 
Javascript :: emotion react 
Javascript :: loop through all dom elements javascript 
Javascript :: How to hthe amount of users online in discordjs 
Javascript :: express routing 
Javascript :: notice before reload js 
Javascript :: mongoose get document 
Javascript :: react add inline styles in react 
Javascript :: javascript check if null 
Javascript :: react in laravel 
Javascript :: table sort datatable 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =