Print the JS source code of the specified area on the page

Source: Internet
Author: User

When I was working on the Campus Network Homepage of Hubei University, there was a printing function in this week's conference topic, mainly through marking a printing start marker and a ending marker on the webpage, use the string method to intercept the characters between the two marker, and finally use window. print () method for printing!

PasteCode:

<SCRIPT type = "text/JavaScript"> function printhytz () {bdhtml = Invalid Response Doc ument. Body. innerhtml; // obtain the entire page string sprnstr = '<! -- Beginprint --> '; eprnstr =' <! -- Endprint --> '; prnhtml = bdhtml. substr (bdhtml. indexof (sprnstr) + 17); // obtain the string prnhtml = prnhtml. substring (0, prnhtml. indexof (eprnstr); // obtain the string of the specified region. body. innerhtml = "<br> <font style = 'font-size: 14px; font-family:; '>" + prnhtml + "</font> "; // reset the webpage content window. print (); // call the print () method of the window object to print.} </SCRIPT> <! -- Beginprint --> area to be printed <! -- Endprint -->

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.