Hallo ihrs,
ich habe im Netz ein (wie ich finde) recht gutes Script für eine Browserweiche gefunden. Hintergrund ist, dass mein neues Projekt keinen NS 4.x mehr verträgt und ich einen Besucher mit NS 4.x abfangen möchte und Ihn um ein update auf einen neuen Browser bitten möchte.
Klappt auch alles hervorragend mit den Microsoft und auch Opera Browsern und die Versionen werden auch richtig erkannt, aber wie ist es mit Browsern wie Mozilla, Crazybrowser, Conqueror (Linux), Irgendwelche AOL Sachen etc.
Hat jemand Erfahrung wie ich das Script erweitern müsste damit es komplett wird oder deckt das Script bereits jetzt schon alles ab?
Testen kann man die Weiche hier: http://www.haarformer.com
Das Script erlaubt im Beispiel:
IE >= 5.0
NS >= 6.0
Opera >= 6.0
Vielen Dank für die Hilfe.
Gruß
Achim
Hier isses nun:
var useragent = navigator.userAgent;
var bName = (useragent.indexOf('Opera') \> -1) ? 'Opera' : navigator.appName;
var pos = useragent.indexOf('MSIE');
if (pos \> -1)
{
bVer = useragent.substring(pos + 5);
var pos = bVer.indexOf(';');
var bVer = bVer.substring(0,pos);
}
var pos = useragent.indexOf('Opera');
if (pos \> -1)
{
bVer = useragent.substring(pos + 6);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape")
{
var bVer = useragent.substring(8);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape" && parseInt(navigator.appVersion) \>= 5)
{
var pos = useragent.lastIndexOf('/');
var bVer = useragent.substring(pos + 1);
}
// IE 3 Weiterleitung
if(bName=="Microsoft Internet Explorer"&&bVer \>="3.0" &&bVer \<"4.0")
{
location="alterbrowser.html";
}
// IE 4 Weiterleitung
if(bName=="Microsoft Internet Explorer"&&bVer \<"5.5" &&bVer \>="4.0")
{
location="alterbrowser.html";
}
// IE 5 Weiterleitung
if(bName=="Microsoft Internet Explorer"&&bVer \<"5.5" &&bVer \>"4.5")
{
location="content/start.html";
}
// IE 5.5 Weiterleitung
if(bName=="Microsoft Internet Explorer"&&bVer =="5.5")
{
location="content/start.html";
}
// IE 6 Weiterleitung
if(bName=="Microsoft Internet Explorer"&&bVer \>"5.5")
{
location="content/start.html";
}
// Opera 3 Weiterleitung
if(bName=="Opera"&&bVer \>="3.0" && bVer \< "4.0")
{
location="alterbrowser.html";
}
// Opera 4 Weiterleitung
if(bName=="Opera"&&bVer\>="4.0" &&bVer \< "5.0")
{
location="alterbrowser.html";
}
// Opera 5 Weiterleitung
if(bName=="Opera"&&bVer\>="5.0" &&bVer \< "6.0")
{
location="alterbrowser.html";
}
// Opera 6 Weiterleitung
if(bName=="Opera"&&bVer\>="6.0" &&bVer \< "7.0")
{
location="content/start.html";
}
// Opera 7 Weiterleitung
if(bName=="Opera"&&bVer\>="7.0" &&bVer \< "8.0")
{
location="content/start.html";
}
// Netscape 4.x Weiterleitung
if(bName=="Netscape"&&bVer \>="4.0" &&bVer \< "5.0")
{
location="alterbrowser.html";
}
// Netscape 6 Weiterleitung
if(bName=="Netscape"&&bVer \>="6.0" &&bVer \< "7.0")
{
location="content/start.html";
}
// Netscape 7 Weiterleitung
if(bName=="Netscape"&&bVer \>="7.0" &&bVer \< "8.0")
{
location="content/start.html";
}
//--\>