// 获取当前页面的完整 URL
var currentUrl = window.location.href;
console.log("当前页面的完整 URL 是: " + currentUrl);
// 获取当前页面的路径部分(不包含域名)
var currentPath = window.location.pathname;
console.log("当前页面的路径是: " + currentPath);
// 获取当前页面的查询参数部分
var queryParams = window.location.search;
console.log("当前页面的查询参数是: " + queryParams);
// 获取当前页面的 hash 部分
var hash = window.location.hash;
console.log("当前页面的 hash 是: " + hash);
window.location.href:返回当前页面的完整 URL。window.location.pathname:返回当前页面的路径部分,不包含域名和查询参数。window.location.search:返回当前页面的查询参数部分(即 URL 中 ? 后面的部分)。window.location.hash:返回当前页面的 hash 部分(即 URL 中 # 后面的部分)。上一篇:js 爬虫
下一篇:js 数组转成字符串
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站