Home > Web Front-end > JS Tutorial > According to the IP address, distinguish different regions and view the js code of different website pages_javascript skills

According to the IP address, distinguish different regions and view the js code of different website pages_javascript skills

WBOY
Release: 2016-05-16 17:41:23
Original
1359 people have browsed it

I have been busy building a website recently, but after I finished it, I felt that it was not so satisfactory. I still need to make some adjustments. Depending on the region, I looked at different website pages. Since the pages I generated were all static, it was really a bit confusing. Embarrassing, I have published some articles on this before, but I still feel it is quite troublesome, and I cannot achieve satisfactory results. Therefore, with the help of my friends, I found a more convenient method, which is to add the following code , adding it to the page we need to jump to is a good idea!

Copy code The code is as follows:


<script> <br>var sf=ILData[2]; <br>if( sf.indexOf("Beijing")>=0){ <br>window.location.href="http://www.jb51.net/"; <br>} <br>else if(sf.indexOf( "Hebei")>=0){ <br>window.location.href="http://www.jb51.cn"; <br>} <br>else if(sf.indexOf("Tianjin")&gt ;=0){ <br>window.location.href="http://www.jb51.org"; <br>} <br></script>


http://www.jb51.net/ This is our website address. If you also need to open different website pages according to different regions, just change it to your own website. This method is good, and it is also here. I hope to communicate with you more. If you have a good method, you can share it!
Related labels:
ip
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template