Play Flash Games


© 2007 Red Computer

HTML Howto, CSS Howto, JavaScript Howto, PHP Howto, Windows Howto
Google

Center A New Window


Capture screen size to make a new window display on the center of the screen. :

<script type="text/javascript">
function openWindow() {
    var screenWidth=screen.width
    var screenHeight=screen.height

    var windowWidth=400
    var windowHeight=200

    var leftPos=Math.round((screenWidth/2)-(windowWidth/2))
    var topPos=Math.round((screenHeight/2)-(windowHeight/2))

    window.open("/blank.htm","win","left=" + leftPos + ",
	top=" + topPos + ", width=" + windowWidth + ",height=" + windowHeight)
}
</script>

<form>
	<input type="button" value="Open New Window" onclick="openWindow()"/>
</form>

This is the result : (Click the button to see)





Visitor's Comment

Post a Comment
Comment
Name :
E-mail :

HOME | HTML | CSS | JavaScript | PHP | XML | SQL | Virus Fix | Windows | Downloads | Links