Visa ett inlägg
Oläst 2008-04-27, 22:58 #7
objx objx är inte uppkopplad
Medlem
 
Reg.datum: Mar 2008
Inlägg: 154
objx objx är inte uppkopplad
Medlem
 
Reg.datum: Mar 2008
Inlägg: 154
Om du bara behöver besökarens upplösning för att avgöra vilka bakgrundsbilder som skall användas, och andra layoutmässiga variationer så skulle jag hellre låta javascriptet använda skärmupplösningen för att lägga till ett CSS-stylesheet, än att ladda om hela sidan.
Det tjänar både dina besökare tid på samtidigt som du sparar bandbredd.

Läs mer om hur du gör det här:
http://juicystudio.com/article/acces...ookmarklet.php

Hittade en javascript-funktion som skall vara cross-browser. Kanske något du kan ha nytta av eftersom det finns webbläsare som inte klarar av kommandot screen.width och screen.height:


function getWindowSize() {
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;
}
return [ myWidth, myHeight ];
}



Kör sedan något i stil med:
...
<head>

<script type="text/javascript">
var res = getWindowSize();

if(res[0] == 1024 && res[1] == 768){
/* javascript som lägger till ditt stylesheet för 1024x768 */
}else if(res[0] == 1280 && res[1] == 1024){
....
}else{
....
}
</script>
</head>
....
objx är inte uppkopplad   Svara med citatSvara med citat