Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 865 Bytes

current-url.md

File metadata and controls

33 lines (20 loc) · 865 Bytes
标题 标签
currentURL(当前路径) browser,beginner(浏览器,初学者)

返回当前路径。

  • 使用Window.location.href得到当前路径。

代码如下:

const currentURL = () => window.location.href;

ts 代码如下:

调用方式:

currentURL(); // 'https://www.google.com/'

应用场景

以下是一个实战示例:

结果如下:

<iframe src="codes/javascript/html/current-url.html"></iframe>