正如我们所知,JQuery Mobile 在服务器重定向方面存在问题。
网站上只有一个安全页面的最佳方式是什么?
这是场景:
- 用户转到站点的根目录 ->
- 用户进入支付页面->
- <- 服务器将用户重定向到 https 支付页面 #在这一步我们可以 使用 data-ajax=false
- 支付页面的用户转到任何其他页面 -> #We should have all data-ajax=false 页面上的链接?看起来很糟糕。什么是适当的 将用户从该页面转移到不安全页面的方法?
UPD 这个问题不仅与移动网站有关,而且与所有大量使用 ajax 的网站有关。
最佳答案
处理此问题的一种方法是检测进行跨域 AJAX 调用所固有的页面加载失败并尝试更改协议(protocol)。 AJAX 和页面转换将无法使用这种方法,但是,它可以防止您在网站上乱放 data-ajax=false
属性。这适用于两个方向(即往返 HTTPS)。
$(document).bind("pageloadfailed", function (event, data) {
// Let the framework know we're going to handle things.
event.preventDefault();
// Attempt to change protocols
window.location.href = data.absUrl.indexOf('https://') > -1 ?
data.absUrl.replace('https://', 'http://') :
data.absUrl.replace('http://', 'https://');
// At some point, if the load fails, either in this
// callback, or through some other async means, call
// reject like this:
data.deferred.reject(data.absUrl, data.options);
});
关于javascript - JQuery 手机。网站上只有一个 https 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12214093/