Identify different regions based on the IP address and view the JS Code of Different website pages

Source: Internet
Author: User

I have been busy with website construction recently, but after doing a good job, I feel that it is not so satisfactory. I have to make some moves. I want to view different website pages based on different regions, since the pages I generated are static, it is a bit difficult. I have also published some of these issues before. ArticleBut it is still quite troublesome, and it cannot achieve the satisfactory results. So, with the help of a friend, find a more convenient way Code, Add to the page we need to jump to, this is still good!

Copy codeThe Code is as follows: <SCRIPT src = "http://counter.sina.com.cn/ip" type = "text/JavaScript" charset = gb2312> </SCRIPT>
<SCRIPT>
VaR Sf = ildata [2];
If (SF. indexof ("Beijing")> = 0 ){
Window. Location. href = "http://www.jb51.net /";
}
Else if (SF. indexof ("Hebei")> = 0 ){
Window. Location. href = "http://www.jb51.cn ";
}
Else if (SF. indexof ("Tianjin")> = 0 ){
Window. Location. href = "http://www.jb51.org ";
}
</SCRIPT>

Success!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.