Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

how to code print in javascript

console.log("print")
//or
alert("Print")
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to use media queries in emotion 
Javascript :: getboundingclientrect() javascript 
Javascript :: chartjs hide text inside bar 
Javascript :: javascript function argument type 
Javascript :: js read from json1 
Javascript :: click outside react component 
Javascript :: new gatsby project 
Javascript :: how to fix Composer could not find a composer.json file in Z:xampp 7312htdocsproject_karakter-master 
Javascript :: check data type in javascript 
Javascript :: js toggle class 
Javascript :: NameError: uninitialized constant Shoulda 
Javascript :: TypeError: client.guilds.forEach is not a function 
Javascript :: nested loops js 
Javascript :: export default arrow function 
Javascript :: async in useeffect 
Javascript :: react-router-dom navlink active 
Javascript :: jquery get meta value 
Javascript :: semantic ui dropdown value react 
Javascript :: Properly upgrade node using nvm 
Javascript :: validate phone number javascript 
Javascript :: part of sting js 
Javascript :: install aos angular 10 
Javascript :: golang parse jason 
Javascript :: javascript pass object by value 
Javascript :: open modal in jqwuery 
Javascript :: loop through array backwards 
Javascript :: indexOf by object key 
Javascript :: prepend to array javascript 
Javascript :: useref array of refs 
Javascript :: js array set value at index 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =