I’m really not a fan of popup windows within a website. But sometimes it really makes sense. For example for a little campaign which is more or less a microsite. But you want not to lose the website context. In this case i would „allow“ to open the campaign in a popup window.

The popup window should of course be as small as possible and should resize to the campaigns size. But because you never know which kind of Browsertoolbars the user have installed ( and you don’t want to disallow all tool- and browserbars ) you can’t really set the window size, because the IE does not support the innerHeight or innerWidth attribute of the window-element.

Mozilla based browsers do support it and resize the complete window that way, that all content is fully shown. The following script checks the browsers scroll attibute to resize the IE browser window step by step. Not very nice, but it works. Please let me know if there is a better way to to this. This is the first i found.

function setInnerSize(width,height) {
 
    if (window.innerWidth && window.innerWidth!="undefined") {
     	window.innerWidth = width;
     	window.innerHeight = height;
    }else{
     	run = true;
     	runHeight = height;
     	runWidth = width;
 
     	window.resizeTo( runWidth, runHeight );
     	while( run  ){
      		window.scrollTo( 1000, 1000 );
      		scrollV = (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
      		scrollH = (document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
 
      		if( scrollH > 0 ) runWidth = runWidth+10;
      		if( scrollV > 0 ) runHeight = runHeight+10;
 
      		window.resizeTo( runWidth, runHeight );
 
      		if(  (scrollV+scrollH)<10 ) run = false;
     	}
    }
}

cheers,
Sebastian

1 thought on “ Set innerHeight also for IE ”

  1. Hi Sebastian,

    I came across your post for reszing FF and IE by specifying the innerHeight and it works great. Any idea on a script that will work in Safari and Chrome as well?

    Cheers

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert