// 获取当前页面的完整 URL
var currentUrl = window.location.href;
console.log(currentUrl); // 输出当前页面的完整 URL
// 如果只想获取当前页面的路径部分(不包括域名)
var currentPath = window.location.pathname;
console.log(currentPath); // 输出当前页面的路径部分
// 如果只想获取查询参数部分
var queryParams = window.location.search;
console.log(queryParams); // 输出查询参数部分,例如 "?id=123"
// 如果只想获取 hash 部分
var hash = window.location.hash;
console.log(hash); // 输出 hash 部分,例如 "#section1"
上一篇:js url decode
下一篇:js 获取url地址
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站