且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在客户端使用JavaScript来检测页面是否已加密?

更新时间:2023-12-03 10:12:40

使用 window.location.protocol 检查是否 https:

function isSecure()
{
   return window.location.protocol == 'https:';
}

如果您没有本地,您可以省略指定窗口范围内的位置。

Alternatively you can omit specifying "window" if you don't have a locally scoped location.

function isSecure()
{
   return location.protocol == 'https:';
}