REGISTER FREE to Receive Instant Job

Tuesday, 18 November 2014

Opening a Popup and Print window at center of the screen

You can open popup and Print window through javascript. But opening it at center of the screen will make it look good for all size of screen and print page. Following is the way to do it.

Copy Code and Run...

<html xmlns="">
<script type="text/javascript">    
function PrintDiv() {  
var divToPrint = document.getElementById('divToPrint');
var width = 400;
var height = 300;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
var popupWin ='', '_blank', windowFeatures);;
popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
<body >
other contents
<div id="divToPrint">
<div style="width:200px;height:300px;background-color:teal;">
This is the div to print
<input type="button" value="print" onclick="PrintDiv();"/>

1 comment:

  1. Thanks for sharing this great. Keep sharing more useful and conspicuous stuff like this. Thank you so much


Popular Posts

Powered by Blogger.

About Me

My photo

JobsAcid is a 'job search engine' to provide finding a job on the internet easier for the user. It has designed as huge selection of job offerings on the same search engine.