实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> </body> <script> document.write('浏览器代码名字:'+navigator.appCodeName+'<br/>'); document.write('浏览器名称:'+navigator.appName+'<br/>'); document.write('浏览器版本:'+navigator.appVersion+'<br/>'); document.write('浏览器编译平台:'+navigator.platform+'<br/>'); document.write('浏览器语言:'+navigator.language+'<br/>'); document.write('浏览器用户的表头信息:'+navigator.userAgent+'<br/>'); info = navigator.userAgent; //alert(info); ch = info.search(/Chrome/); ff = info.search(/Firefox/); ie = info.search(/MSIE/); if(ch !=-1){ document.body.style.backgroundColor="green"; } if(ff !=-1){ document.body.style.backgroundColor="pink"; } if( ie !=-1){ document.body.style.backgroundColor="yellow"; } </script> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例