Page Printing in JavaScrpit

Ratings:
(4)
Views:641
Banner-Img
  • Share this blog:

 

Javascript Page Printing

Many times you would like to give a button at your webpage to print out the content of that webpage via an actual printer.

Javascript helps you to implement this functionality using the print function of a window object.

The javascript print function window.print() will print the current webpage when execute. You can call this function directly using on click event as follows:

<head>

<script type=”text/javascript”>

<!- -

//--  >

</script>

</head>

<body>

<form>

<input type=”button value=”print “ onclick =”window.print():/>

</form>

</body>

If you want to enrich your career and become a professional in JavaScript, then visit Tekslate - a global online training platform: "JavaScript Training"   This course will help you to achieve excellence in this domain.

How to print a page:

If someone is providing none of the above facilities then you can use browsers standard tool bar to get tht webpages printed out. Follow the link as follows:

File   2 print   2 Click OK button.

JavaScript-Page Redirection

When you click a URL to reach a page X but internally you are directed to another page Y that simply happens because of page re-direction.

<head>

<script type=”text/javascrpit”>

function fun1(){

window location =http://www.newlocation.com;

}

</script>

</head>

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.