inherit
25142
0
Apr 3, 2019 20:28:05 GMT -8
BrotherHolmes
I'm studying for my A+
741
May 2004
redmage
|
Post by BrotherHolmes on Sept 4, 2005 10:06:42 GMT -8
I have used screen.width in some codes, but that only works for the actual screen size.
I have a 1280 screen width, but I always keep my browser window at a width of 1024. I haven't found any way to get the WINDOW width.
Can someone help me?
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Sept 4, 2005 12:54:50 GMT -8
<script type='text/javascript'> <!--
function getWindowInner(){ return { width: (window.innerWidth)? window.innerWidth : document.body.clientWidth }; }
alert(getWindowInner().width);
//--> </script>
I done it so it returns an object so you can extend it if needed
|
|
inherit
25142
0
Apr 3, 2019 20:28:05 GMT -8
BrotherHolmes
I'm studying for my A+
741
May 2004
redmage
|
Post by BrotherHolmes on Sept 4, 2005 13:35:38 GMT -8
I tried that, but it only gets the frame's width. I just changed it to "window.outerWidth" and it got what I wanted.
<script type="text/javascript"> document.write("Inner resolution: ") document.write(window.innerWidth + "*" + window.innerHeight) document.write("<br />") document.write("Outer resolution: ") document.write(window.outerWidth + "*" + window.outerHeight) </script>
Writes: "Inner resolution: 498*400 Outer resolution: 1024*800"
But that 800 is WITH toolbars too! I tried "window.availHeight" but that didn't get anything. Besides that (which is not a major deal)....
THANK YOU! ;D
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Sept 4, 2005 13:41:15 GMT -8
IE offers no properties for getting the outer width/height, why I gave the inner . So your code will only work for browsers like NN4 +, FF
|
|
inherit
25142
0
Apr 3, 2019 20:28:05 GMT -8
BrotherHolmes
I'm studying for my A+
741
May 2004
redmage
|
Post by BrotherHolmes on Sept 4, 2005 13:52:25 GMT -8
aw, Does it give you the frame's width in IE too?
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Sept 4, 2005 13:58:25 GMT -8
Which do you mean? outerWidth?
window.outerWidth won't work in IE at all, not for windows, or frames. You would need to use the way I posted, but if you don't want the scrollbars to be included in the width, you will need to take off between 16 - 20 pixels.
|
|
inherit
25142
0
Apr 3, 2019 20:28:05 GMT -8
BrotherHolmes
I'm studying for my A+
741
May 2004
redmage
|
Post by BrotherHolmes on Sept 4, 2005 15:39:27 GMT -8
Neither work in the code I was using for IE.
The reason I asked in the first place is because I'm trying to make that banner width code that I was trying to get you to make for me, but never heard any more about it, so I thought I'd just study javascript myself and try making one.
Most people have their browsers maxed anyways right? I could just use screen.width
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Sept 5, 2005 1:31:07 GMT -8
Just do a few banners for the screen width, don't worry about the size of the users window.
If you get me all the resolutions you want to cater for, then I will write you the script. Or you can attempt it yourself, just start with something like...
var theBanner; switch(screen.width){ case 1024 : theBanner = "URL to banner for this res"; break; default : theBanner = "default banner to show, probably for 800 res users"; }
|
|
inherit
25142
0
Apr 3, 2019 20:28:05 GMT -8
BrotherHolmes
I'm studying for my A+
741
May 2004
redmage
|
Post by BrotherHolmes on Sept 5, 2005 6:20:18 GMT -8
Going by that code, would a 1280 get the default?
also,... Would I have to setup an array to change the first pic on the page, or is there a class set to the site's banner?
|
|
inherit
Proboards Legend
212
0
May 11, 2006 12:32:55 GMT -8
california
21,035
December 1999
california
|
Post by california on Sept 5, 2005 16:59:28 GMT -8
document.getElementsByTagName("img")[0].src = theBanner;
|
|
inherit
27036
0
Feb 20, 2006 16:04:52 GMT -8
R.S.Big Dawg
HERE I AM
427
July 2004
dirtysanchez
|
Post by R.S.Big Dawg on Sept 6, 2005 9:52:54 GMT -8
Tys all that explain my screenwide
|
|