Home  >  Article  >  Web Front-end  >  How to use JS to determine the current domain name and jump to the specified page

How to use JS to determine the current domain name and jump to the specified page

一个新手
一个新手Original
2017-09-11 09:37:544470browse

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

8019067d09615e43c7904885b5246f0a
        if (window.location.href.indexOf("www.xt.com") > -1) {
        document.write("34ea6544322564608ed2b6317046f1d171821010b2043eaddf6d5fab180f769d介绍5db79b134e9f6b82c0b36e0489ee08edbed06894275b65c1ab86501b08a632eb");
        } else if (window.location.href.indexOf("www.gzxt.com") > -1) {
        document.write("34ea6544322564608ed2b6317046f1d14bafb88b9960390bf003a7918743acc4介绍5db79b134e9f6b82c0b36e0489ee08edbed06894275b65c1ab86501b08a632eb");
        } else if (window.location.href.indexOf("www.gzxt.com") > -1) {
        document.write("34ea6544322564608ed2b6317046f1d12c1b3831a17b8b264f8a5cbfe8152b4b介绍5db79b134e9f6b82c0b36e0489ee08edbed06894275b65c1ab86501b08a632eb");
        }        
2cacc6d41bbb37262a98f745aa00fbf0

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn