location

location的属性
/*href:完整的url地址*/
console.log(location.href);
/*网络传输协议*/
console.log(location.protocol);
/*主机名称*/
console.log(location.hostname);
/*端口号*/
console.log(location.port);
/*返回主机名和端口号*/
console.log(location.host);
/*返回?以后的区域*/
console.log(location.search);
/*返回锚点区*/
console.log(location.hash);
/*返回页面的路径*/
console.log(location.pathname);

location的方法

function baidu() {
    /*加载新的页面,并且可以可以实现路径的点击回退*/
    location.assign("http://www.baidu.com")
}
function reloadPage() {
    /*reload():重新加载当前页面
    * reload(true):彻底的重新加载当前页面,不从缓存取东西*/
    location.reload(true);
}

function replacePage() {
    /*加载新的页面,但是新页面完全把老页面替换,不能返回。*/
    location.replace("http://www.baidu.com");
}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值