Js calls to the printer to print a web page font are always one size smaller solution

  • 2020-03-30 01:29:15
  • OfStack

Today, I want to do a small function of printing a web page, directly call window.print(), but after printing out, the font is always reduced by one, I can't find the reason...

Later, I tried to use an IE print control, but only supported IE a bit disgusting, can only go back to continue to find the reason

Originally, I want to print the page because it is brother pop-up layer, so there is this phenomenon, then direct target="_blank", you can print normally.

In addition,
 
function preview() 
{ 
bdhtml=window.document.body.innerHTML; 
sprnstr="<!--startprint-->"; 
eprnstr="<!--endprint-->"; 
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+17); 
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); 
window.document.body.innerHTML=prnhtml; 
window.print(); 
} 
</script> 

Will < ! - startprint - > And < ! - endprint - > At the beginning and end of the content that needs to be printed, only the required parts are printed, not the entire page. (read someone else's blog, heh heh)

Related articles: