Detect current page with JavaScript
This question already has an answer here:
例如,您可以通过执行以下操作来获取URL:
window.location.href
If you want to know what age they are on, it really depends on the url structure. But you will get the information with window.location.pathname
var pathname = window.location.pathname;
switch(pathname) {
case "/home" :
console.log("home");
break;
case "/game" :
console.log("game");
break;
}
链接地址: http://www.djcxy.com/p/70234.html
下一篇: 使用JavaScript检测当前页面