标签:
例1:通过用户头代理判断浏览器信息
<!DOCTYPE html> <html> <head> <meta charset=’utf-8′> <title></title> <script src=’public.js’></script> </head> <body> <script> var str = window.navigator.userAgent; if(str.indexOf(‘MSIE’)>0){ document.write(“IE浏览器”); }else{ document.write(‘w3c浏览器’); } </script> </body> </html>
示例代码:
<!DOCTYPE html> <html> <head> <meta charset=’utf-8′> <title></title> <script src=’public.js’></script> <script> window.onload = function(){ $(‘btnok’).onclick = function(){ //以前我们是使用location.assign(‘http://www.baidu’);直接进行跳转的 location.href=(‘http://www.baidu.com’); } } </script> </head> <body> <input type=”button” id=”btnok” value=”跳转”> </body> </html>
示例代码:
<!DOCTYPE html> <html> <head> <meta charset=’utf-8′> <title></title> <script src=’public.js’></script> </head> <body> <script> document.write(‘可用宽度’+window.screen.availWidth); document.write(‘可用高度’+window.screen.availHeight); </script> </body> </html>
示例代码:
<!DOCTYPE html> <html> <head> <meta charset=’utf-8′> <title></title> <script src=’public.js’></script> </head> <body> <script> function display(){ if(document.title==’Document对象详解’){ document.title=’【有新消息】 – Document对象详解‘; }else{ document.title=’Document对象详解‘; } setTimeout(‘display()’,1000); } window.onload = function(){ display(); } </script> </body> </html>
夺命雷公狗---javascript NO:19 Navigator浏览器对象
标签:
原文地址:http://www.cnblogs.com/leigood/p/5031920.html