freeCodeCamp/guide/chinese/javascript/tutorials/get-current-url-in-javascript/index.md

370 B
Raw Blame History

title localeTitle
Get Current Url in JavaScript 在JavaScript中获取当前URL

要获取当前网址

var url = window.location.href; 

要获取当前路径

var path = window.location.path; 

有关位置对象及其属性的更多信息,请参见此处