1,js判断当前域名
代码示例:
if(location.toString().indexOf("abc.com") <= -1) /*如果当前网址中没有abc.com*/
{
document.location.href="/b.htm"; /*跳转到b.htm*/
}
else
{
document.location.href="/a.htm"; /*有的话,跳转到a.htm*/ }
{
document.location.href="/b.htm"; /*跳转到b.htm*/
}
else
{
document.location.href="/a.htm"; /*有的话,跳转到a.htm*/ }
2,s获取当前域名
代码示例:
<script language="javascript">
//获取域名
host = window.location.host;
host2=document.domain;
//获取页面完整地址
url = window.location.href;
document.write("<br>host="+host)
document.write("<br>host2="+host2)
document.write("<br>url="+url)
</script>