Results 1 to 6 of 6

Thread: Windows Size Not Screen Size

  1. #1

    Thread Starter
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158

    Question Windows Size Not Screen Size

    How can I get the current windows size. I want to centre a windows when it displays, currently I developed the following method but I have to put the window size in myself, I want it to be able to retrieve the current windows size automatically.

    Code:
    <script language="JavaScript">
        self.resizeTo(640,480)
        
        xWidth = ( screen.availWidth - 640 ) / 2;
        yHeight = ( screen.availHeight - 480 ) / 2;
        
        self.moveTo(xWidth,yHeight)
    </script>

  2. #2
    scoutt
    Guest
    how about this? works in IE3 and NS3
    Code:
    <html>
    <head>
    <title>Centered pop-up window</title>
    
    <SCRIPT LANGUAGE="JavaScript" type="text/Javascript">
    function popUpCenteredWindow() {
    	var iMyWidth;
    	var iMyHeight;
    	//gets top and left positions based on user's resolution so hint window is centered.
    	iMyWidth = (window.screen.width/2) - (122 + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
    	iMyHeight = (window.screen.height/2) - (27 + 50); //half the screen height minus half the new window height (plus title and status bars).
    	var win2 = window.open("","Window2","status,height=55,width=245,resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
    	win2.focus();
    }
    </SCRIPT>
    </head>
    
    <body>
    <A HREF="javascript:void(0);" onClick="popUpCenteredWindow();">open a new window centered on the screen regardless of user's resolution.
    </A>
    
    </body>
    </html>

  3. #3
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Cool, thanks, i have been looking for that for a long time!

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  4. #4
    scoutt
    Guest
    no problem, I'm just glad someone around here knows how to appreciate someone else's help and says thank you. I have answered a few posts and the guy doesn't respond with anything like thanks or that don't work. So I don't know if I am helping or not. maybe I'll just stop helping people that don't appreciate these forums.

  5. #5
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Some people get mad when people do simple "thank you" posts because it adds to their post count when they didn't really answer a question. I don't really care though, because i am not answering questions for my health. I like to know when i helped someone, and i like to know when someone helped me. Who cares what the post count is!

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  6. #6
    scoutt
    Guest
    exactly!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width