判斷訪問指定域名,進行頁面跳轉
<!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>