location 对象
- hostname
- port
- protocol
- href
- hash
- hashChange
- search
- reload()
- replace()
location 地址: 地址栏相关的信息
console.log(location);
host: “127.0.0.1” 主机信息 域名 + 端口 如:127.0.0.1:8080
hostname: “localhost” 主机地址 || 域名
href 完整的地址
port: 端口
pathname: 路径 (当前网页在服务器中具体路径)
protocol: “http”||“https” <协议>(基本就有这两种网络协议,大部分是http,有些追求安全性用https)
hash 代表了 # 后边跟随的是hash 关于hash后面会详述
method:GET/POST/ (具体后面章节再讨论)
<form action="https://www.baidu.com/s" method="GET">
<input type="search" name="wd" />
<input type="submit" />
</form>
search 代表了 ?后边跟随的内容<上图表单提交的数据>, ?wd=CSDN
注意: (get方式提交过来的数据在地址栏中呈现)(post方式提交的数据无法在地址栏中呈现)
<form action="https://www.baidu.com/s" method="GET">
<input type="search" name="wd" />
<input type="search" name="xiao" />
<input type="search" name="di" />
<input type="submit" />
</form>
(后续待补充)