Created
July 29, 2011 12:00
-
-
Save Amitesh/1113683 to your computer and use it in GitHub Desktop.
Open popup window in center of screen in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var top = window.screen.height - 300; | |
top = top > 0 ? top/2 : 0; | |
var left = window.screen.width - 400; | |
left = left > 0 ? left/2 : 0; | |
var uploadWin = window.open(url,"Upload Chapter content","width=400,height=300" + ",top=" + top + ",left=" + left); | |
uploadWin.moveTo(left, top); | |
uploadWin.focus(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This can be used also to center popup window in center of screen in javascript
var width = 600;
var height = 600;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var popup = window.open(pdfUrl, "_blank", "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);