Code To Open popup window in Center Position

Santosh4u
Posted by Santosh4u under JavaScript category on | Views : 19845
Below Code will Helpful to open a popup in Centre Position

Write this Java script code in header section
<script type="text/javascript">
// Code For Centered popup window
function popup(url)
{
var width = 300;
var height = 200;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height;
params += ', top='+top+', left='+left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=no';
params += ', status=no';
params += ', toolbar=no';
newwin=window.open(url,'windowname5', params);
if (window.focus) {newwin.focus()}
return false;
}

Write Below code in your body section
<a href="javascript: void(0)" 
onclick="popup('Revarse.aspx')">Centered popup window</a>


With Regards
Santosh

Comments or Responses

Login to post response