---
title: "JS小结"
author: "msongli"
date: "2014-04-10T11:12:47Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2014-04-10T11:13:42Z"
id: 1312398
url: "https://msongli.iteye.com/blog/1312398"
---

我的js经验小结

 

js浏览器类型检查

 

写道

var agent = window.navigator.userAgent;

if (agent.indexOf("MSIE 6") != -1) {  
alert("IE6");  
}  
else if (agent.indexOf("MSIE 7") != -1) {  
alert("IE7");  
}  
else if (agent.indexOf("MSIE 8") != -1) {  
alert("IE8");  
}  
else if (agent.indexOf("Firefox") != -1) {  
alert(" Firefox ");  
}  
else if (agent.indexOf("Chrome") != -1) {  
alert(" Chrome ");  
}  
else if (agent.indexOf("Safari") != -1) {  
alert(" Safari ");  
}

 

 

js获取浏览器路径

 

写道

var url = window.location.href;