日期:2014-05-16  浏览次数:20302 次

关于用javascript修正网址的问题~~
我现在遇到一个问题,就是让用户通过一个text   input输入一个网址
但是用户可能并不一定输入   http://www.domain.com/aaa.htm   这样的标准网址
有可能是输入:
www.domain.com/aaa.htm
Http://www.domain.com/aaa.htm
hTTp://www.domain.com/aaa.htm

那么遇到这些情况的时候我怎么把上面的网址改变为:
http://www.domain.com/aaa.htm

请高手赐教~~无限感激~~

------解决方案--------------------
location.hostname+ "/ "+location.pathname
------解决方案--------------------
用正则表达式。
------解决方案--------------------
var url = "hTTp://www.domain.com/aaa.htm ";
url = url.toLowerCase();
alert(url);
------解决方案--------------------
document.localhost.href