HEJ!
Du letar efter window.resizeTo(outerWidth, outerHeight). http://www.devguru.com/Technologies/ecmascript/quickref/window.html
5 svar · 269 visningar · startad av mattiasnordin
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?
HEJ!
Du letar efter window.resizeTo(outerWidth, outerHeight). http://www.devguru.com/Technologies/ecmascript/quickref/window.html
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"
?
outerheight är inte samma sak som outerHeight.
<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?!
<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>