Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Getting browser window height in IE



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
mwa103
100+ Club


Joined: 07 Mar 2005
Posts: 206

PostPosted: Thu Aug 17, 2006 4:09 pm    Post subject: Getting browser window height in IE Reply with quote

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! Twisted 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
View user's profile Send private message MSN Messenger
Samuel Rounce
100+ Club


Joined: 30 Oct 2005
Posts: 116
Location: London, UK

PostPosted: Fri Aug 18, 2006 10:20 am    Post subject: Re: Getting browser window height in IE Reply with quote

You could just use percentages for the heights and widths of the 3 main divs instead of using lots of Javascript.
Back to top
View user's profile Send private message AIM Address MSN Messenger
mwa103
100+ Club


Joined: 07 Mar 2005
Posts: 206

PostPosted: Fri Aug 18, 2006 1:56 pm    Post subject: Re: Getting browser window height in IE Reply with quote

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
View user's profile Send private message MSN Messenger
Samuel Rounce
100+ Club


Joined: 30 Oct 2005
Posts: 116
Location: London, UK

PostPosted: Fri Aug 18, 2006 3:50 pm    Post subject: Re: Getting browser window height in IE Reply with quote

Yeah I'm using it on a site at the moment with no problems whatsoever in any browsers.
Back to top
View user's profile Send private message AIM Address MSN Messenger
mwa103
100+ Club


Joined: 07 Mar 2005
Posts: 206

PostPosted: Fri Aug 18, 2006 3:55 pm    Post subject: Re: Getting browser window height in IE Reply with quote

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
View user's profile Send private message MSN Messenger
mwa103
100+ Club


Joined: 07 Mar 2005
Posts: 206

PostPosted: Wed Aug 23, 2006 12:02 am    Post subject: Re: Getting browser window height in IE Reply with quote

Ok, as Samuel suggested, I'm going a different (JS Free) route on this one now. I found a template here: http://www.cssplay.co.uk/layouts/bodyfix.html
that does exactly what I want. It also works perfect in FF, but for some reason IE wont scroll the overflow even though it is set to overflow: auto.
Anybody see anything I missed? It works fine on his site, but mine doesn't want to scroll. I had to change a few sizes for the header, footer, and content. Other than that it's the same css. Any assistance is appreciated.

my site again: http://www.wiu.edu/users/mwa103/2col
site's css pages:
main-http://www.wiu.edu/users/mwa103/2col/scroll2col.css
menu-http://www.wiu.edu/users/mwa103/2col/menu.css

Thanks
-Mike
Back to top
View user's profile Send private message MSN Messenger
mwa103
100+ Club


Joined: 07 Mar 2005
Posts: 206

PostPosted: Wed Aug 23, 2006 11:46 pm    Post subject: Re: Getting browser window height in IE Reply with quote

Finnaly got it. It wasn't a problem with my css at all. Confused 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. Laughing 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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap