http和https以及跨域


http

https

https 会阻挡别的域名调用该连接的图片资源

跨域

https://www.liaoxuefeng.com/wiki/001434446689867b27157e896e74d51a89c25cc8b43bdb3000/001434499861493e7c35be5e0864769a2c06afb4754acc6000

1
2
3
4
5
6
7
// 转为http;
var targetProtocol = "http:";
// 转为https;
var targetProtocol = "https:";
if (window.location.protocol != targetProtocol)
window.location.href = targetProtocol +
window.location.href.substring(window.location.protocol.length);
0%