| Site Map | WizTools.org | jCraze Blog |
![]() |
JavaScript Screen SizeEver wondered how to find the screen resolution of the user? It is very simple in JavaScript: <script language="javascript"> var w = screen.width; // Get the width of the screen var h = screen.height; // Get the height of the screen </script> So want to find your screen resolution? Find! Opening A Centered WindowSo wouldn't you like to use the above trick for some useful purpose? How about opening a centered window? Use this code:
<script language="javascript">
function openCentered(){
var w = screen.width; // Get the width of the screen
var h = screen.height; // Get the height of the screen
// The size of the Window
var win_width = w - 350;
var win_height = h - 250;
// Where to place the Window
var left = (w - win_width)/2;
var top = (h - win_height)/2;
var features = 'width='+win_width+',height='+win_height
features += ',top='+top+',left='+left+',screenX='+left+',screenY='+top;
var win = window.open('', '', features);
win.document.write('<html><head><title>JavaScript Eg.</title></head>');
win.document.write('<body><h2>indiWiz.com JavaScript Example</h2></body></html>');
win.document.close();
}
</script>
Call this function. |
Sign Guestbook
|
Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.