webForumDet fria alternativet

Automatiskt byta storlek på webläsarfönstret till 800 x 600

JavaScript

5 svar · 269 visningar · startad av mattiasnordin

Medlem sedan maj 20012 080 inlägg
Frågan#1

Hej hopp...

Finns det något enkelt sätt att byta storlek på ett öppnat webfönster om det öppnade fönstret skulle vara mindre än 800 pixlar brett?

Medlem sedan apr. 20031 660 inlägg
#2

HEJ!

Du letar efter window.resizeTo(outerWidth, outerHeight). http://www.devguru.com/Technologies/ecmascript/quickref/window.html

Medlem sedan maj 20012 080 inlägg
#3

Borde man inte kunna göra något liknande:

<SCRIPT LANGUAGE="javascript">
alert(window.outerheight)
if(window.outerheight < 900){
window.resizeTo(900, outerHeight)
}
</script>

Alerten returnerar: "undefined"

?

Medlem sedan juni 200032 967 inlägg
#4

outerheight är inte samma sak som outerHeight.

Medlem sedan maj 20012 080 inlägg
#5
<SCRIPT LANGUAGE="javascript">
alert(window.outerHeight)
if(window.outerheight < 900){
window.resizeTo(900, outerHeight)
}
</script>

Ger samma resultat. If satsen fungerar inte heller :(

Vad gör jag för fel. Det här borde väl vara oerhört trivialt?!

Medlem sedan maj 20012 080 inlägg
#6
<SCRIPT LANGUAGE="javascript">
function changeWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	varChangeToWidth = 900 		//New widht
	myHeight = myHeight + 200	//Orkar inte fixa om funktionen för att hanter outerWidth istället för innerWidht 
	// window.alert( 'Height = ' + myHeight );
	if (myWidth < varChangeToWidth){
	window.resizeTo(varChangeToWidth, myHeight)
  	}
}
changeWindowSize() //Startar funktionen
</script>
263 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
130 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)