Toon posts:

[javascript] opvragen precieze browserversie

Pagina: 1
Acties:
  • 109 views sinds 30-01-2008

Verwijderd

Topicstarter
Ik wil een check doen op een browser en op internet lees ik constant dit:
[javascript]if (navigator.appName != "Microsoft Internet Explorer" || navigator.appVersion > "4.0"[/javascript]

Maar in appversion gebruikt ie dan waarde 4.0 ipv mijn browser ie5. Ligt dit soms aan het feit dat ik draai onder windows nt 4? Wat kan ik aan dit script veranderen zodat hij toch 5 terugeeft?

  • TiG
  • Registratie: Maart 2001
  • Laatst online: 29-06 14:19

TiG

Van http://www.wiserways.com/web-tech/tips/script-tips.htm
The appVersion property of JavaScript's Navigator object returns the version of the current browser, along with information about the browser's platform. For example, running Internet Explorer 4.0 in Windows 95 would create the following value for the appVersion property:

4.0 (compatible; MSIE 4.01 Windows 95)

You might, at first glance, assume that you can simply extract the first character of the appVersion string to determine the version of Internet Explorer that you're using. However, that first number is the compatible Netscape version; the Internet Explorer version is actually to be found in the string "MSIE 4.01." To extract the Internet Explorer version from the string, try using a combination of the indexOf() and charAt() String methods, as in:

function getversion()
{
//Get the position of the string "MSIE" in the appVersion string
position = navigator.appVersion.indexOf("MSIE" )

//If the string is found
if (position >-1)
{
//Move to the position of the version number and test
switch (navigator.appVersion.charAt(position+5))
{
case "3":
alert("Using Internet Explorer 3")
break
case "4":
alert("Using Internet Explorer 4")
break
case "5":
alert("Using Internet Explorer 5")
break
}
}
else
alert("Not using Internet Explorer")
}

U gaat door voor de retorische vraag...


  • TiG
  • Registratie: Maart 2001
  • Laatst online: 29-06 14:19

TiG

oeps, zag net pas dat dit van 31 januari 2001 was. Foutje :o

U gaat door voor de retorische vraag...


  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

mag dus op slot, hoort niet in P&W en oud ;)

Dit topic is gesloten.