Size of the window

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Stoyanski
Forum Newbie
Posts: 15
Joined: Sun Jun 02, 2002 9:33 am
Location: BG
Contact:

Size of the window

Post by Stoyanski »

Hello to all,
Can You tell me how to get the width & height of the browsers window. In one book (O'Rielly, "JavaScript", David Flanagan, 2000) I read that Netscape 4 supports some sort of 'outerWidth' & 'outerHeight' but nothing for IE.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

IE has these properties
Konqueror and opera are going to implement most of IE's features (or already have). HTML-DOM 2.0 seems to be a good approach as all of them claim to implement it in newer versions.
opera spec

I've been ignoring Netscape for quite a while since it failed so many of my tests. But as mentioned this was 'long ago', things may have improved. I'll give it a try in the near future ( ;) )
Stoyanski
Forum Newbie
Posts: 15
Joined: Sun Jun 02, 2002 9:33 am
Location: BG
Contact:

Post by Stoyanski »

I'm trying to get (find out) the size of the WINDOW not DOCUMENT. The script actually resizes the window [javascript:resizeTo(w,h);] and to center it [javascript:moveTo(w,h);] I need to know EXACT width & height to do this.
Got it?
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Trying to find the screen resoltion might be better, as finding the window size won't make it any easier to center it.
Stoyanski
Forum Newbie
Posts: 15
Joined: Sun Jun 02, 2002 9:33 am
Location: BG
Contact:

Post by Stoyanski »

jason wrote:Trying to find the screen resoltion might be better, as finding the window size won't make it any easier to center it.
I just want to know the damned WindowSize is that so difficult?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

the problem is that you want to receive the browser-width and -height.

Code: Select all

posX = (screen.width - document.body.offsetWidth) / 2;
almost does it for the x-coord. But

Code: Select all

posY = (screen.height - document.body.offsetHeight) / 2;
does not measure the window-title or tools-bars. I found no way to get these values from INSIDE the document (which does not mean, that there is no way ;) )
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Stoyanski wrote:
jason wrote:Trying to find the screen resoltion might be better, as finding the window size won't make it any easier to center it.
I just want to know the damned WindowSize is that so difficult?
1. Chill out. I don't tolerate rudeness on these boards, especially from someone who hasn't contributed back. You have been warned. Now, back to being civilized.

2. I hope this helps: http://web-wise-wizard.com/javascript-r ... ation.html I googled for it and like I said, it should do the trick. :D
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

sorry, this one fails as well. it only checks for innerWidth
1. Chill out. I don't tolerate rudeness on these boards, especially from someone who hasn't contributed back. You have been warned. Now, back to being civilized.
he may be a little bit annoyed since he ICQed me and it took a while 'til I got the point ;)
Stoyanski
Forum Newbie
Posts: 15
Joined: Sun Jun 02, 2002 9:33 am
Location: BG
Contact:

Post by Stoyanski »

I think the 'innerWidth' will do the job.

PS:
That was a bad start for me in this forum, but I will do my best.
Last edited by Stoyanski on Mon Jun 03, 2002 4:54 pm, edited 1 time in total.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

It's all good. We are forgiving here. Hey, people come in, they make a mistake, you point it out, and it's over. I would just rather tackle things early and risk a broken ego or two than not say anything.

:D

No hard feelings of course. 8)
Post Reply