Dom元素及其操作
- Document Object model(文件对象模型)
document对象
html文档都会变成
- document.head
- document.body
readyState
返回当前文档状态
- loading:加载HTML代码阶段,尚未完成解析
- interactive:加载外部资源阶段
- complete:全部加载完成
documnet.location
- // 假定当前网址为http://user:passwd@www.example.com:4097/path/a.html?x=111#part1
- document.location.href // “http://user:passwd@www.example.com:4097/path/- - a.html?x=111#part1”
- document.location.protocol // “http:”
- document.location.host // “www.example.com:4097”
- document.location.hostname // “www.example.com”
- document.location.port // “4097”
- document.location.pathname // “/path/a.html”
- document.location.search // “?x=111”
- document.location.hash // “#part1”
- document.location.user // “user”
- document.location.password // “passed”
// 跳转到另一个网址
- document.location.assign(‘http://www.google.com’)
// 优先从服务器重新加载 - document.location.reload(true)
// 优先从本地缓存重新加载(默认值) - document.location.reload(false)
// 跳转到另一个网址,但当前文档不保留在history对象中,
// 即无法用后退按钮,回到当前文档 - document.location.assign(‘http://www.google.com’)
// 将location对象转为字符串,等价于document.location.href - document.location.toString()documnet.location.href 获取地址的缓存