主页 > 前端 > javascript >
来源:未知 时间:2018-04-09 15:48 作者:小飞侠 阅读:次
[导读] JavaScript 的document对象中有一个location的子对象,其包括是属性如下: document.location.host //表示当前域名 + 端口号 document.location.hostname //表示域名 document.location.href //表示完整的URL document....
JavaScript 的document对象中有一个location的子对象,其包括是属性如下: document.location.host //表示当前域名 + 端口号 document.location.hostname //表示域名 document.location.href //表示完整的URL document.location.port //表示端口号 document.location.protocol //表示当前的网络协议 所以通过上面第五条就能判断当前的网络协议了,具体判断如下: var protocolStr = document.location.protocol; if(protocolStr == "http") { console.log("protocol = " + protocolStr); } else if(protocolStr == "https") { console.log("protocol = " + protocolStr); } else { console.log("other protocol"); } |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com