推荐
<script><BR>function isMatch(str1,str2) <BR>{ <BR>var index = str1.indexOf(str2); <BR>if(index==-1) return false; <BR>return true; <BR>} <BR>alert(window.location.hostname);<BR>if (isMatch(window.location.hostname,'www.jb51.net') == false){window.location.href="http://www.jb51.net";}<BR></script>
下面我们一个网站开发中用到的
function gotourl()
{
var url = "http://www.jb51.net";
var localurl = document.url;
if( localurl.substring(0,url.length) != url )
{
location.href=url;
}
}
gotourl();