Is there any way to detect HTTP or HTTPS and then force usage of HTTPS with JavaScript?(有没有办法检测HTTP或HTTPS,然后强制使用HTTPS与JavaScript?)
I have some codes for detecting the HTTP or HTTPS but I can't force it to use https:
.(我有一些用于检测HTTP或HTTPS的代码,但我不能强迫它使用https:
.)
I'm using the window.location.protocol property to set whatever the site is to https:
then refresh the page to hopefully reload a new https'ed URL loaded into the browser.(我正在使用window.location.protocol属性来设置站点到https:
任何内容https:
然后刷新页面以希望重新加载加载到浏览器中的新https'ed URL。)
if (window.location.protocol != "https:") {
window.location.protocol = "https:";
window.location.reload();
}
ask by Registered User translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…