Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

js 获取当前url

作者:冫LOVE灬丶棒棒   发布日期:2025-11-22   浏览:93

// 获取当前页面的完整 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地址

大家都在看

js 数组对象排序

js 数组删掉第一个值

js fill

js 数组连接

js json数组

js 数组复制

js 复制数组

js 数组拷贝

js 对象数组合并

js 对象转数组

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站