In JavaScript you can check whether the url/website accessed is over Http
or Https
, via 2 ways
window.location.protocol
which returnshttp:
orhttps:
window.isSecureContext
which returnstrue
forhttps
andfalse
forhttp
.
I know that window.isSecureContext
is non-standardised. But lets say I know it is available at the client browser.
Then,
- what is the difference between the two read-only values? Which one to use?
- Most Importantly, In which case would there be an anomaly. Meaning, first method says
https:
while second saysfalse
or other way around.