Document.location.host // indicates the current domain name+port number.
Document.location.hostname // stands for domain name.
Document.location.href // represents the full URL.
Document.location.port // indicates the port number.
Document.location.protocol // indicates the current network protocol.
Therefore, the current network protocol can be judged by Article 5 above, and the specific judgment is as follows:
[javascript] View Plain Text
var protocol str = document . location . protocol;
if(protocolStr == "http ")
{
console . log(" protocol = "+protocol str ");
}
else if(protocolStr == "https ")
{
console . log(" protocol = "+protocol str ");
}
other
{
Console.log ("other protocols");
}