JavaScript学习笔记14

it2023-03-04  87

location()

document.write("<h3>location对象</h3>"); document.write("<br>主机名"+location.hostname +"<br>"); document.write("<br>端口名"+location.port +"<br>"); document.write("<br>主机加端口名"+location.host +"<br>"); document.write("<br>当前文档URL"+location.href +"<br>"); document.write("<br>时间"+new Date().toLocaleString()+"<br>");

history()

<input type="button" value="刷新" onclick="location.reload()"/>//location.reload()刷新页面 <br> <a href="09window窗口对象.html">window窗口对象</a> <input type="button" value="返回" onclick="history.back()"/>//返回页面 <input type="button" value="返回" onclick="history.go(-1)"/>//向后返回一次 <input type="button" value="前进" onclick="history.forward()"/>//前进 <input type="button" value="前进" onclick="history.go(1)"/><br>//前进 <!-- 按钮当作超链接 --> <input type="button" value="window窗口对象" onclick="location.href='09window窗口对象.html'"/>//点击按钮实现跳转 <a href="javascript:history.go(1)">前进3</a>//javascript:加上后,history.go(1)才不会被当作地址,而作为js执行

navigator

document.write("<h3>navigator对象</h3>"); document.write("<br>浏览器名称"+navigator.appName +"<br>"); document.write("<br>浏览器版本"+navigator.appVersion +"<br>"); document.write("<br>浏览器类型"+navigator.userAgent +"<br>"); document.write("<br>操作系统"+navigator.platform +"<br>"); document.write("<br>是否启用java"+navigator.javaEnabled()+"<br>");
最新回复(0)