Download Fore_End/JavaScript/BOM/04_Location对象.html from zxy0307/JavaWeb: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/zxy0307/JavaWeb/resolve/main/Fore_End/JavaScript/BOM/04_Location%E5%AF%B9%E8%B1%A1.html
- Command line
-
hf download hf://zxy0307/JavaWeb/Fore_End/JavaScript/BOM/04_Location对象.html
-
curl -L -o 04_Location对象.html https://huggingface.co/zxy0307/JavaWeb/resolve/main/Fore_End/JavaScript/BOM/04_Location%E5%AF%B9%E8%B1%A1.html
1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Location对象</title> | |
| </head> | |
| <body> | |
| <input type="button" id="btn" value="刷新"> | |
| <input type="button" id="goBaidu" value="去百度"> | |
| <script> | |
| /* | |
| Location:地址栏对象 | |
| 1. 创建(获取): | |
| 1. window.location | |
| 2. location | |
| 2. 方法: | |
| * reload() 重新加载当前文档。刷新 | |
| 3. 属性 | |
| * href 设置或返回完整的 URL。 | |
| */ | |
| //reload方法,定义一个按钮,点击按钮,刷新当前页面 | |
| var btn = document.getElementById("btn"); | |
| btn.onclick = function() { | |
| location.reload(); | |
| } | |
| //获取href | |
| var href = location.href; | |
| alert("href=" + href); | |
| var btn2 = document.getElementById("goBaidu"); | |
| btn2.onclick = function() { | |
| location.href="http://www.baidu.com"; | |
| } | |
| </script> | |
| </body> | |
| </html> |