开发者

Converting URL to HTTPS via Javascript

I want to convert current url to https version with javascript. How can i done this ?

Ex: http://www.example.开发者_StackOverflow社区com --> https://www.example.com


window.location = window.location.href.replace(/^http:/, 'https:');


If you know that your http URL starts with "http://", then it is as simple as:

var httpsUrl = "https" + httpUrl.substring(4);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜