Skip to content

分析拆解 url 各个部分

location 和 history

js
// location
console.log(location.href);
// http://localhost/test/test.html?a=100#100
console.log(location.protocol); // http:
console.log(location.host); // localhost
console.log(location.search); // ?a=100
console.log(location.hash); // #100
console.log(location.pathname); // /test/test.html
// history
history.back(); // 后退
history.forward(); // 前进

基于 MIT 许可发布