如何使用JavaScript返回网页的协议(http或https)?
使用window.location对象返回协议。该窗口。升ocation.protocoL将返回网络协议,即无论是HTTP 或HTTPS-
示例
<!DOCTYPE html> <html> <body> <script> document.write("https or https: <br>The protocol is:"+window.location.protocol); </script> </body> </html>