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