js判断当前页面是http还是https

来源:互联网 发布:蓝牙打印机打印软件 编辑:程序博客网 时间:2024/06/06 01:32

通过一下方式可以判断当前页面是 http 还是 https

var ishttps = 'https:' == document.location.protocol ? true: false;

if(ishttps){

 alert("这是一个https请求");

}else{

 alert(“这是一个http请求”);

}

原创粉丝点击