请问判断一个字符以"http://"开头,如何判断?
请问判断一个字符以"http://"开头,如何判断? 问题点数:6、回复次数:3Top
1 楼hax(海曦)回复于 2006-03-03 11:50:15 得分 6
if (s.indexOf('http://') == 0) {
... do sth
}Top
2 楼KimSoft(革命的小酒天天醉-http://blog.csdn.net/kimsoft/)回复于 2006-03-03 12:30:49 得分 0
<SCRIPT LANGUAGE="JavaScript">
<!--
var url = "http://www.sina.com"
if (url.indexOf('http://') != -1) {
alert(url + "是以http://开头的")
} else {
alert(url + "不是以http://开头的")
}
//-->
</SCRIPT>Top
3 楼kangqin(小康)回复于 2006-03-03 12:50:20 得分 0
<script>
alert(/^http:\/\//.test("http://csdn.net"));
</script>Top




