JavaScript中的location、history、navigator对象实例介绍(js location replace)这样也行?

随心笔谈12个月前发布 admin
98 0

//地址栏上#及后面的内容
console.log(window.location.hash);
//主机名及端口号
console.log(window.location.host);
//主机名
console.log(window.location.hostname);
//文件的路径—相对路径
console.log(window.location.pathname);
//端口号
console.log(window.location.port);
//协议
console.log(window.location.protocol);
//搜索的内容
console.log(window.location.search);
//设置跳转的页面的地址
location.href=”http://www.jb51.net”;//属性—————–>必须记住
location.assign(“http://www.jb51.net”);//方法
//重新加载–刷新
location.reload();
//没有历史记录
location.replace(“http://www.jb51.net”);

© 版权声明

相关文章