JS 判断域名并跳转到指定页面

判断访问指定域名,进行页面跳转

<!DOCTYPE html>
<html>
<head>
	<title>正在玩命加载中……</title>
	<!-- 判断来路域名自动跳转 -->
	<script type="text/javascript">
	    var href = location.href ;  //获取当前请求路径
        if (href.indexOf("vipsoft") > -1) {
            //跳转
            location.href = "http://www.vipsoft.com.cn/vipsoft.html";
        } else if (href.indexOf("eicrosoft") > -1) {
        	window.location.href='http://www.vipsoft.com.cn/eicrosoft.html';
        }
    </script>
</head>
<body>
 
</body>
</html>

不同的域名 输出不同的结果

<script type="text/javascript">
        if (window.location.href.indexOf("vipsoft.com.cn") > -1) {
        document.write("<li style='background:none;'><a href='http://www.vipsoft.com.cn/1.html'>介绍</a></li>");
        } else if (window.location.href.indexOf("www.vipsoft.com.cn") > -1) {
        document.write("<li style='background:none;'><a href='http://www.vipsoft.com.cn/2.html'>介绍</a></li>");
        } else if (window.location.href.indexOf("www.eicrosoft.com") > -1) {
        document.write("<li style='background:none;'><a href='http://www.vipsoft.com.cn/3.html'>介绍</a></li>");
        }
 </script>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章