Need help with dynamic div resizing.

Problem with IE (go figure)

Page 1 of 1

3 Replies - 2878 Views - Last Post: 04 October 2008 - 12:33 AM

#1 Daftajest   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 08

Need help with dynamic div resizing.

Posted 02 October 2008 - 08:36 PM

So I'm trying to get my site to dynamically shift with the size of the browser when it loads up...It works fine in Firefox 3, Opera and (as far as I know), FF2.

IE is the only browser that I see that has any problem with it whatsoever, which never ceases to surprise me, as IE tends to eat all forms of code, regurgitate them, and devour the slimy and putrid remains, just to continue the process.

Anyways...I'm not really a whiz at Javascript (just started using it a week ago), and I have no idea how to fix it just for IE...Here it is.

<script type='text/javascript'>
function getPageHeight(){
if(window.innerHeight){
_output=window.innerHeight;
}else{
_output=document.documentElement.clientHeight;
}
return _output;
}
function getPageWidth(){
if(window.innerWidth){
_output=window.innerWidth;
}else{
_output=document.documentElement.clientWidth;
}
return _output;
}
</script>


<script type='text/javascript'>
document.getElementById('leftcol').style.height=getPageHeight()-125-48+'px';
document.getElementById('maincol').style.height=getPageHeight()-126-48+'px';
document.getElementById('maincol').style.width=getPageWidth()-152+'px';
document.getElementById('speakmain').style.height=getPageHeight()-148-32+'px';
</script>


Is This A Good Question/Topic? 0
  • +

Replies To: Need help with dynamic div resizing.

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5291
  • View blog
  • Posts: 14,125
  • Joined: 18-April 07

Re: Need help with dynamic div resizing.

Posted 02 October 2008 - 10:12 PM

Do you have an actual URL that you can show us with? Then please describe what you see in FF versus IE. Screenshots would be helpful too.

:)
Was This Post Helpful? 0
  • +
  • -

#3 Daftajest   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 08

Re: Need help with dynamic div resizing.

Posted 03 October 2008 - 03:11 PM

http://daftajest.com/new

I would post some screenshots, but I'm sure you guys can tell by the urls alone...

EDIT: And the differences are...In IE it just resorts to showing it all and stretching the page, but in FF, it locks in place, and doesn't stretch the page. I know it's not my CSS settings, because it does it when I set it to scroll as well.

This post has been edited by Daftajest: 03 October 2008 - 04:46 PM

Was This Post Helpful? 0
  • +
  • -

#4 tkulev   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-October 08

Re: Need help with dynamic div resizing.

Posted 04 October 2008 - 12:33 AM

Well, the problem is that IE understand a things different from other browsers :)

To get a resolution in all browsers, use :
	
	 if( typeof( window.innerWidth ) == 'number' ) {
		  w	 = document.documentElement.clientWidth;
		  h	 = window.innerHeight;
		  
	 }
	 else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		  w	 = document.documentElement.clientWidth;
		  h	 = document.documentElement.clientHeight;
	 }
	 else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		  w	 = document.body.clientWidth;
		  h	 = document.body.clientHeight;
	 }
	 



But why you use JS to resize this simple block ? You can do this only with css :)

This post has been edited by tkulev: 04 October 2008 - 12:34 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1