Page 1 of 1

Size of the window

Posted: Mon Jun 03, 2002 1:52 pm
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.

Posted: Mon Jun 03, 2002 2:15 pm
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 ( ;) )

Posted: Mon Jun 03, 2002 2:41 pm
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?

Posted: Mon Jun 03, 2002 2:50 pm
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.

Posted: Mon Jun 03, 2002 3:20 pm
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?

Posted: Mon Jun 03, 2002 3:38 pm
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 ;) )

Posted: Mon Jun 03, 2002 4:11 pm
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

Posted: Mon Jun 03, 2002 4:18 pm
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 ;)

Posted: Mon Jun 03, 2002 4:49 pm
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.

Posted: Mon Jun 03, 2002 4:51 pm
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)