Segue um Código JavaScript para Detecção de Browsers
<script type="text/javascript" language="javascript">
/*****************************
Função para Detecção de Browser
******************************/
function Browser( )
{
var agent = navigator.userAgent.toLowerCase();
this.isPocket = ( navigator.appVersion.indexOf( "MSIE" ) > 0 ) && ( navigator.appVersion.indexOf( "Windows CE" ) > 0 );
this.isPPC = agent.indexOf( "240x320" ) > 0;
this.isWin = agent.indexOf( "win" ) > 0;
this.isUNIX = agent.indexOf( "x11" ) > 0;
this.isMac = agent.indexOf( "mac" ) > 0;
this.isAOL = agent.indexOf( "aol" ) > 0;
this.isIE = agent.indexOf( "msie" ) > 0;
this.isNS6 = agent.indexOf( "netscape6" ) > 0;
this.isGecko = agent.indexOf( "gecko" ) > 0;
this.isFF = agent.indexOf( "firefox") > 0;
this.isNS4 = ( document.layers ) ? true : false;
this.iWidth = window.screen.width;
this.iHeight = window.screen.height;
}
//Inicializa tipo do browser
var browser = new Browser( );
</script>
Para Utilizar, basta chamar o Objeto (browser) e as propriedades que indicam o tipo do browser (isAOL, isIE, etc).
Exemplo:
<script type="text/javascript" language="javascript">
alert("Internet Explorer: " + browser.isIE);
alert("FireFox: " + browser.isFF);
alert("Netscape 4: " + browser.isNS4);
alert("Netscape 6: " + browser.isNS6);
</script>
Posts Relacionados:



Be the first to start a conversation