JavaScript实现http地址自动检测并添加URL链接 function changeUrl(str){ var reg = /(http://|https://)((w|=|?|.|/|&|-)+)/g; str= str.replace(reg, "<a href='$1$2'>$1$2</a>"); return str } 本文转自地址:http://www.zhangxinxu.com/wordpress/?p=749