SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist Fleeters's Avatar
    Join Date
    Jul 2003
    Location
    Dumpsville
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with javascript script..

    I am working on a solution gfor resizing a div element depending on size of browser..

    heres is my script:

    Code:
    <script type="text/javascript">
    function size() 
    {
    
      if( typeof( window.innerWidth ) == 'number' ) 
      {
      	//Non-IE
      	alert("non ie");
      	if( window.innerHeight < 450 )
      	{
          document.getElementById('flashcontent').style.height = 600 + 'px';
        }
        else
        {
          document.getElementById('flashcontent').style.height = 100 + '%';
        }
    	
      } 
      else if( document.documentElement && (document.documentElement.clientHeight ) ) 
      {
      	//IE 6+ in 'standards compliant mode'
      	alert("IE A");
      	if( document.documentElement.clientHeight < 450 )
      	{ 
          document.getElementById('flashcontent').style.height = 600 + 'px';
        }
        else
        {
          document.getElementById('flashcontent').style.height = 101 + '%';
        }
        
      } 
      else if( document.body && ( document.body.clientHeight ) ) 
      {
      	//IE 4 compatible
      	alert("IE B");
      	if( document.body.clientHeight < 450 )
      	{
          document.getElementById('flashcontent').style.height = 600 + 'px';
        }
        else
        {
          document.getElementById('flashcontent').style.height = 101 + '%';
        }
      }
      
      alert("IE3");
      
    }
    window.onload = function() 
    { 
    	size();
    }
    window.onresize = function() 
    {
    	size();
    }
    
    alert(" start ");
    
    </script>

    this works great in Firefox, for some reason it doesn't do anything in IE.. the "start" alert happens, but non of the other alert's happen to see where in the logic it is going.. I can't figure out what is wrong with the IE one??
    Aaron Smith
    smithaaronlee.net

  2. #2
    SitePoint Zealot yacka's Avatar
    Join Date
    Aug 2006
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure? It works in IE 6, Firefox & Opera for me.

    IE at load:
    start
    IE B
    IE3

    IE on resize:
    IE B
    IE3
    IE B
    IE3

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Fleeters,

    Why start another thread when this one was fine?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •