javascript: Weiterleitung anhand Bildschirmauflösung

Um einen User auf eine Seite weiterzuleiten, die seiner Bildschirmauflösung angepasst ist kann man folgenden Code benutzen :


  1. <script language="javascript">
  2. var breite = screen.width;
  3. var aufl =(((!(640-breite))*1)
  4. +((!(800-breite))*2)
  5. +((!(1024-breite))*3)
  6. +((!(1152-breite))*4)
  7. +((!(1280-breite))*5)
  8. +((!(1600-breite))*6));
  9. if(!(aufl)) aufl = 1;
  10. if (aufl=="1") { window.location="./640x480.html"; }
  11. if (aufl=="2") { window.location="./800x600.html"; }
  12. if (aufl=="3") { window.location="./1024x768.html"; }
  13. if (aufl=="4") { window.location="./1152x864.html"; }
  14. if (aufl !="1" && aufl !="2" && aufl!="3" && aufl!="4") { window.location="./index.html"; }
  15. </script>
 
 
© onvice 2002 - 2010