| View previous topic :: View next topic |
| Author |
Message |
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Thu Aug 17, 2006 4:09 pm Post subject: Getting browser window height in IE |
|
|
I need another set of eyes on this one. I'm rebuilding a website using css instead of tables. So far, so good. At least it is for FF, IE is another story. I've set up the page to discover the users browser window height and resize content acordingly. This works fine in FF, but IE doesn't want to play ball.
http://www.wiu.edu/users/mwa103/2col/
The code I'm using to get browser size:
| Code: |
<script language="javascript">
winW1=document.body.clientWidth;
winW2=window.innerWidth;
winH1=document.body.clientHeight;
winH2=window.innerHeight;
if(winW1 > 0)
winW=winW1;
else
{
if(winW2 > 0)
winW=winW2;
else
winW=700;
}
if(winH1 > 0)
winH=winH1;
else
{
if(winH2 > 0)
winH=winH2;
else
winH=500;
}
if(winW < 801)
{
var winH = winH-220;
}
else var winH = winH-290;
if(winH < 200) var winH = 200;
</script> |
This same code worked great using cookies, but cookies are the evil! I don't know whether it's the location of the code on the page or what now. Your comments are greatly appreciated.
Thanks
-Mike |
|
| Back to top |
|
 |
|
|
Samuel Rounce 100+ Club

Joined: 30 Oct 2005 Posts: 116 Location: London, UK
|
Posted: Fri Aug 18, 2006 10:20 am Post subject: Re: Getting browser window height in IE |
|
|
| You could just use percentages for the heights and widths of the 3 main divs instead of using lots of Javascript. |
|
| Back to top |
|
 |
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Fri Aug 18, 2006 1:56 pm Post subject: Re: Getting browser window height in IE |
|
|
| I've tried using percentages for height before, but Safari didn't like that. Maybe I was doing it incorectly though. Have you used % before with success? |
|
| Back to top |
|
 |
Samuel Rounce 100+ Club

Joined: 30 Oct 2005 Posts: 116 Location: London, UK
|
Posted: Fri Aug 18, 2006 3:50 pm Post subject: Re: Getting browser window height in IE |
|
|
| Yeah I'm using it on a site at the moment with no problems whatsoever in any browsers. |
|
| Back to top |
|
 |
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Fri Aug 18, 2006 3:55 pm Post subject: Re: Getting browser window height in IE |
|
|
Could I get you to give me an example of how to make % work correctly, or maybe just a URL I can look at which uses % for height so I can figure it out myself. Thanks.
-Mike |
|
| Back to top |
|
 |
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
|
| Back to top |
|
 |
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Wed Aug 23, 2006 11:46 pm Post subject: Re: Getting browser window height in IE |
|
|
Finnaly got it. It wasn't a problem with my css at all. All I needed to do was add one line to the begining of my document:
| Code: |
| <!-- Put IE into quirks mode --> |
I just missed it from the original document when building mine. Aparently IE won't work as good as Firefox unless you make it go goofy. Anyways, thanks to everyone who took a look at this for me. I think I'm ready to make the change live now. As always, any comments about the site are greatly appreciated.
Thanks again
-Mike |
|
| Back to top |
|
 |
|