赞
踩
JavaScript 的document对象中有一个location的子对象,其包括是属性如下:
所以通过上面第五条就能判断当前的网络协议了,具体判断如下:
- 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");
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。