【发布时间】:2014-05-11 13:31:48
【问题描述】:
HTTP 速度快(在初始页面加载时),而 HTTPS 是安全的。我有一个站点 example.com,仅在用户登录时才需要安全(它使用安全 cookie 进行身份验证)。
速度是第一印象中最重要的因素之一,我想提供正常的 HTTP 页面 (http://example.com),然后使用 Javascript 懒惰地升级到 HTTPS。
if ( location.protocol === 'http:' ) {
$.ajax({
url: 'https://example.com',
cache: true,
success: function() {
window.top.location.replace('https://example.com');
}
);
}
这样做会导致页面在新页面加载时“闪烁”。有没有一种方法可以让用户不那么明显?
【问题讨论】:
标签: javascript html ssl https