简体   繁体   中英

Check if site is HTTPS or HTTP?

Okay so I am making a little chrome extension for my company. I want them to be alerted if they are entering a NON-Secure HTTP website.

Now I have found this little script:

 if (isSecureContext) { alert('Browsing is HTTPS'); }

So if you run this, you can see it says its HTTPS. But if you go to an HTTP website, I want an alert Browsing is not secured. I tried the ELSE, statement. But that doesn't work for me.

Could somebody help me to write an else statement or something along those lines that it will alert if you are on Non HTTPS?

Thanks, Markus

else should work

Try Else if() {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM