Zden Novak

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromZden Novak
ToMe
SubjectIs there a way to use alertSize with resizeTo and without alert?
Date27 June 2004 23:41
In my naivety, I thought I could use alertSize to get out how much screen I
can use after resizeTo(screen.width,screen.heigth).

1st try:
- a HTM which includes in the BODY tag resizeTo 300,300 and moveTo 0,0.
- alertSize code included in SCRIPT section
- replaced window alert with document write
- the output is over 300

2nd try:
- put alertSize in a JS
- deleted window alerts
- made it return myHeight
- from HTM
 - printed myHeight
 - called alertSize with alert

The size printed is most probably the window size before resizeTo - I cannot
get the value after resizeTo without an alert call. (Same in IE, Netscape,
Mozilla).

Just one more disappointment with HTML and JavaScript.

Zden

P.S. Great site, congratulations.

Z.
FromMe
ToZden Novak
SubjectRe: Is there a way to use alertSize with resizeTo and without alert?
Date28 June 2004 08:45
Zden,

It is important to note that my alertSize function checks the size of the
_inside_ of the window, but resizeTo changes the size of the outside, so
the measurements will always be different. There is no fully cross browser
way to work out the size of the outside, but since you used resizeTo, you
already know what size the outside is.

But your initial assumption was correct. You can use alertSize to check the
size at any time, although of course, you need to return the values as you
have done instead of alerting the size as I had done.

Assuming you have set it to return the values instead of alerting them:
return [myHeight,myWidth]; //for example
You can then use this to obtain the size:
resizeTo(screen.availWidth,screen.availHeight);
var sizes = alertSize();
var theWidth = sizes[0];
var theHeight = sizes[1];
You can now use theWidth and theHeight in any of your calculations.

Note, instead of using screen.width and screen.height, I use
screen.availWidth and screen.availHeight. This is the available screen
space, and it accounts for space required by the Windows taskbar, Mac menus
etc.

Just as a side note, you can write document content after the page has
loaded, but not using document.write, since the behaviour of that method
changes after the page completes loading. You can do it like this:
<p id="writeHere"></p>
...
document.getElementById('writeHere').innerHTML = 'some new content';


Hope this helps


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.