Published September 12, 2020
Often time we may want to do some processes like handling payments, accessing private information, working with service workers, etc. on our web app or web page. These activities should only be done when the current web page context is secure or if the context is
The easy way to check if the current context of a web page is
HTTPS enabled is to check using the
isSecureContext property in the window object.
// check if the current context is HTTPS enabled const isItHTTPS = window.isSecureContext; console.log(isItHTTPS); // true
- The property returns a boolean
trueif the current context is
See this snippet live in JSBin.