// 获取当前页面的完整URL
var currentUrl = window.location.href;
console.log(currentUrl); // 输出当前页面的完整地址
// 如果只需要获取当前页面的域名部分
var currentDomain = window.location.origin;
console.log(currentDomain); // 输出当前页面的域名,例如: https://www.example.com
// 如果只需要获取当前页面的路径部分
var currentPathname = window.location.pathname;
console.log(currentPathname); // 输出当前页面的路径,例如: /path/to/page.html
window.location.href:返回当前页面的完整 URL。window.location.origin:返回当前页面的协议、域名和端口(如果有)。window.location.pathname:返回当前页面的路径部分。上一篇:js setcookie
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站