3
我想用javascript将当前网址转换为https版本。我怎么做到这一点?通过Javascript将URL转换为HTTPS
例如:http://www.abc.com - >https://www.abc.com
我想用javascript将当前网址转换为https版本。我怎么做到这一点?通过Javascript将URL转换为HTTPS
例如:http://www.abc.com - >https://www.abc.com
window.location = window.location.href.replace(/^http:/, 'https:');
如果你知道你的HTTP URL以 “http://”,那么很简单:
var httpsUrl = "https" + httpUrl.substring(4);
好一个!你可能也想检查它是否为'http:'before:'if(window.location.protocol =='http:'){}' – pex 2010-11-16 03:17:38