Is it possible to detect, on the client side, whether the user is using an encrypted page or not?
Put another way -- I want to know if the URL of the current page starts with http or https.
Is it possible to detect, on the client side, whether the user is using an encrypted page or not?
Put another way -- I want to know if the URL of the current page starts with http or https.
As google analytics taught me:
Use
window.location.protocol
to check if it ishttps:
Alternatively you can omit specifying "window" if you don't have a locally scoped location.
Second method for newest browsers:
or just get isSecureContext:
More here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts#Feature_detection#Feature_detection