JS Call printer Print Web page font always reduce a number of solutions _javascript tips

Source: Internet
Author: User
Today to do a small print web page function, directly call Window.print (), but printed out, the font is always narrowing a number, can not find the reason ...

Later try to use an IE print control, but only support ie a little disgusting, can only return to continue to find the reason

Originally, I want to print the page because it is the elder brother pop-up layer, so appear this kind of phenomenon, later direct target= "_blank", can print normally.

Other than that
Copy Code code as follows:

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>

Place the <!--startprint--> and <!--endprint--> at the beginning and end of the content that needs to be printed, printing only the parts you need, not the entire page. (Look at someone else's blog Oh, hehe)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.