如何在 JavaScript 中删除 URL 中的“ http://”

100880 次浏览
url = url.replace(/^https?:\/\//, '')

I think the regular expression you need is /(?:http://)(.*)/i. The first match of this should be it.

l.href.replace(/^http:\/\//, '')

I think it would be better to take into account all possible protocols.

result = url.replace(/(^\w+:|^)\/\//, '');

Try using replace function

var url = url.replace("http%3A%2F%2F", "");