Location 对象属性

			/*
			Location 对象属性
			*/

			// 创建 a 标签并设置 href 属性
			var url = document.createElement("a");
			url.href = "https://www.runoob.com/?s=python#test";
			console.log(url.href); // https://www.runoob.com/?s=python#test
			console.log(url.protocol); // https:
			console.log(url.host); // www.runoob.com
			console.log(url.hostname); // www.runoob.com
			console.log(url.port); // (输出为空 - https 默认端口为 443)
			console.log(url.pathname); // /
			console.log(url.search); // ?s=python
			console.log(url.hash); // #test
			console.log(url.origin); // https://www.runoob.com

			console.log("-----------------------------------------------")

			var url = document.createElement("a");
			url.href = "http://cashier.pays.com/000000EB9q?daily";
			console.log(url.href); // http://cashier.pays.com/000000EB9q?daily
			console.log(url.protocol); // http:
			console.log(url.host); // cashier.pays.com
			console.log(url.hostname); // cashier.pays.com
			console.log(url.port); // (输出为空 - https 默认端口为 443)
			console.log(url.pathname); // /000000EB9q
			console.log(url.search); // ?daily
			console.log(url.hash); // 
			console.log(url.origin); // http://cashier.pays.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值