How do I determine whether a page is secure via JavaScript? [duplicate] How do I determine whether a page is secure via JavaScript? [duplicate] javascript javascript

How do I determine whether a page is secure via JavaScript? [duplicate]


location.protocol should do it for you.

(as in:

if (location.protocol === 'https:') {    // page is secure}

)


You should be able to check document.location.protocol to see if it's "http:" or "https:"


While location.protocol should do it for you as Peter Stone mentioned, but you shouldn't rely on Javascript for any true security, etc.

I think the value with be "https:" for location.protocol if you are on SSL.