| 标题 | 标签 |
|---|---|
| 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>