Newsgroup: it.comp.www
Titolo: Javascript: quale browser?

         Sandro O.
la variabile REMOTE_AGENT contiene il nome del agente...
pero sia Netscape che MSIE si fanno chiamare entrambi mozilla...
... abuot:mozila
Comunque non ti scordare di chi non usa ne Netscape ne MSIE, c'e' chi
non li usa... pocchi ma ci sono.



Ciao Sandro O.
ti riporto uno stralcio di HTMLib ver. 3.2 (sezione Tips 'n' Tricks),
spero ti possa servire. Ti saluto,
                                           Aldo
	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>

 spero ti possa servire. Ti saluto,
 la soluzione migliore a questo problema e' usare un cgi wrapper 
 sul lato server, in questo modo sara' possibile discriminare 
 qualunque browser e inviare codice html specifico per qualunque
 navigatore che supporti o meno javascript...
 consiglio: php/fi come modulo per apache 
  saluti
   Flare

:>Aldo Parmendola wrote:
:>> 
:>> Ciao Sandro O.
:>> ti riporto uno stralcio di HTMLib ver. 3.2 (sezione Tips 'n' Tricks),
Scusate l'inserimento un po' brutale..., cos'e HTMLib ver. 3.2?
Dove trovarlo?
Grazie, Andrea.
Andrea Penna
ape...@estense.global.it
http://www.aspide.it/freeweb/online
using OS/2 Warp 4.0

Dove trovarlo?
http://subnet.virtual-pc.com/~le387818/
 e' l'indirizzo di riferimento
presente nel file .hlp ma penso che si possa trovare un po' ovunque
(tucows, shareware, windows95). Ciao,
                                                             Aldo