IE zuverlässig erkennen?

Alice

Erfahrenes Mitglied
Hallo.

Gibt es eine Möglichkeit den IE mit PHP zuverlässig zu erkennen?

Ich frage den Browser mit $_SERVER['HTTP_USER_AGENT'] ab und mein IE wurde nicht erkannt, denn mein IE nennt sich WOW64.

Es muss doch eine zuverlässige Methode geben?
 
Nein ich habe keine CSS-Probleme.

Ich wollte nur eine "IE-Fix.css" erstellen die dann für alle IE-Versionen gelten sollte.

Da ich hautsächlich Firefox + Brain.exe verwende, sieht das Layout meistens gut aus.......
 
Serverseitig kannst du IE nicht zuverlässig erkennen, resp. halt nur über den Useragent, der ja auch selbst gesetzt werden kann.
Clientseitig kannst du aber auf Funktionen testen und so theoretisch schon herausfinden um welchen Browser es sich handelt.
So hat z.B. IE8 und jünger keine forEach Funktion bei Arrays. Nun kann man testen ob diese Funktion existiert:
Javascript:
if([1, 2].forEach === undefined)
Allerdings wird es auch noch andere Browser geben, die diese Funktion nicht besitzen. Also müsste man nun weiter machen und Funktionen abfragen, die wiederum nur der IE hat.

Wenn man aber schon so weit geht, muss man nicht mehr Browser unterscheiden, sondern kann anhand der Funktionen die vorhanden sind oder eben nicht unterschiedliche Dinge machen.

Das ganze sage ich jetzt aus Sicht eines JS-Coders, aber für CSS giltet das selbe.

Schau dir mal http://modernizr.com an:
Modernizr is a small JavaScript library that detects the availability of native implementations for next-generation web technologies, i.e. features that stem from the HTML5 and CSS3 specifications. Many of these features are already implemented in at least one major browser (most of them in two or more), and what Modernizr does is, very simply, tell you whether the current browser has this feature natively implemented or not.

Unlike with the traditional—but highly unreliable—method of doing “UA sniffing,” which is detecting a browser by its (user-configurable) navigator.userAgent property, Modernizr does actual feature detection to reliably discern what the various browsers can and cannot do. After all, the same rendering engine may not necessarily support the same things, and some users change their userAgent string to get around poorly developed websites that don’t let them through otherwise.

Modernizr aims to bring an end to the UA sniffing practice. Using feature detection is a more reliable mechanic to establish what you can and cannot do in the current browser, and Modernizr makes it convenient for you in a variety of ways
 

Neue Beiträge

Zurück