1. How to use JS to determine the current domain name and jump to the specified page
获取当前请求路径 var href = location.href ; if(href.indexOf("baidu")>-1){ //跳转 location.href = "http://baidu.com"; }
2.
Today a customer asked his website to enter two different domain names and then load them. Enter the headers of different web pages. Thinking about it, we can only load different CSS through JS judgment.
The code is as follows:
host = window.location.host;if (host=="www.028wz.net") { document.write("<style>")document.write(".head{ background: url(document.write("</style>")}
3. Different domain names output different results
<script type="text/javascript"> if (window.location.href.indexOf("www.xt.com") > -1) { document.write("<li style='background:none;'><a href='http://www.xt.com/yygk/yyjj/915.html'>介绍</a></li>"); } else if (window.location.href.indexOf("www.gzxt.com") > -1) { document.write("<li style='background:none;'><a href='http://www.gzxt.com/yygk/yyjj/916.html'>介绍</a></li>"); } else if (window.location.href.indexOf("www.gzxt.com") > -1) { document.write("<li style='background:none;'><a href='http://www.gzxt.com/yygk/yyjj/917.html'>介绍</a></li>"); } </script>
The above is the detailed content of How to use JS to determine the current domain name and jump to the specified page. For more information, please follow other related articles on the PHP Chinese website!