[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Browsererkennung



At 14:25 01.07.97 +0200, you wrote:
>
>
>Hallo,
>
>wir sind auf der Suche nach einem HTML-Tag, das nach
>dem verwendeten Browser fragt und die Seiten entsprechend 
>einstellt. Kann uns jemand weiterhelfen?
>
>
>Gisela Schmitt
>
>UB Kaiserslautern
>schmitt _at__ ub.uni-kl.de
>
>
>
>

Hallo Frau Schmitt,

nachstehend ein Auszug aus der HTML-Reference Library von Stephen Le Hunte,
der Ihnen vielleicht weiterhilft. Die HTML-Ref Library kann unter folgenden
Adressen bezogen werden: 

NOTE : The whereabouts of the most recent version of this reference can
always be found by going to the HTMLib web site at
http://subnet.virtual-pc.com/~le387818/ or by mailing me at
cmlehunt _at__ swan.ac.uk.  Normally, the most recent version can be found att
ftp.swan.ac.uk in the directory pub/in.coming/htmlib.  A mailing list is
also kept of those people who have expressed an interest in the reference
and will be used to notify them of future releases.  To subscribe to the
mailing list, send mail to me at cmlehunt _at__ swan.ac.uk.  and let me know you
want to be included.



Und hier der Tip...

This tip is possibly misnamed slightly, as using the example script below,
it is only possible to distinguish between Internet Explorer (3.0 and above)
and Netscape (2.0 and above) as it uses the navigator.UserAgent object to
determine the browser type, which can only be interrogated (using non CGI
scripts) for these two browsers.
	This tip is useful if, for example, you have a set of pages that relies
heavily on ActiveX content, that will be unuseable in Netscape.  A button
can be used that runs the browser checking script and re-directs the user to
the correct destination, based on their browser type.  Any wider browser
checking routines require CGI scripting, to trap and interrogate the
HTTP_USER_AGENT field that is sent by every browser to every server when
requesting HTML documents.  (Any CGI reference should contain information on
this topic).

The following script can be used to determine whether the user is using
Internet Explorer or not.


<SCRIPT LANGUAGE="JavaScript">
function browser_check()
 {
 var BrowserType=navigator.userAgent;
 if (BrowserType.indexOf("MSIE") == 25)
   {location.href="index2.html"}
 else {
   location.href="browser_check.html"}
 }
</SCRIPT>

The script is a JavaScript, because it will then check Netscape and Internet
Explorer.  A VisualBasic Script version would only work on Internet
Explorer, thus not fulfilling its purpose.

	Basically, the script takes the navigator.userAgent object and checks to
see whether the string "MSIE" is at the 25th position in the
navigator.userAgent string.  If it is, then the browser loads the page
index2.html else it loads the page browser_check.html.  The two
browser_check.html strings presented by Netscape and Internet Explorer are :

Mozilla/2.0 (compatible;MSIE 3.0A;Windows 95)
Mozilla/3.0b5 (Win95;l)

for Internet Explorer (3.0 beta 2, Windows 95) and Netscape (3.0 beta 5,
Windows 95) respectively.

	The above script could easily be extended to trap any of the contents of
the two navigator.userAgent strings and act accordingly.

	A simple button can be included within the HTML document to run the script
like :


<FORM>
<P><INPUT TYPE="button" VALUE="Check the Browser" NAME="BCheck"
onClick="browser_check()">
</FORM>



Listeninformationen unter http://www.inetbib.de.