With Javascript, we can determine if a connection is encrypted by checking location.protocol
:
if ( 'https:' === location.protocol ) {
// encrypted
} else {
// plaintext / not encrypted
}
But is there a method to determine if the browser believes the connection is secure? I'm looking for a Javascript-programmatic version of when the URL bar shows green or red for an HTTPS connection that is secure or insecure: