Home >Web Front-end >JS Tutorial >js telecom and netcom dual line automatic selection skills_javascript skills

js telecom and netcom dual line automatic selection skills_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:58:32825browse

Let’s not talk about the initial development user groups of our products because it doesn’t make much sense. If you are positioned as a student, then based on our own four-year university experience, the proportion of students using telecommunications and campus networks is basically too variable.
Fortunately, we have now realized dual lines of telecommunications and China Netcom in the north and China Telecom in the south, which is a feature of our country. Even during the Spring Festival of 2007, an internal agreement between China Telecom and China Netcom broke out. The content was probably that the North and the South would not infringe on each other's respective areas. Therefore, if you want to build a successful Internet product, you must not care about where the users come from or what network environment they use. The final solution is dual lines of China Telecom and China Netcom. There is still a gap - the campus network. What is better is that the campus network has a wide direct optical fiber connection with China Netcom, and the physical environment can be solved in meters.

Technical processing

Copy code The code is as follows:

< ;img src="http://www.jb51.net/direct" width="1" height="1" onerror="Javascript:top.location='http://www.jb51.net'">



This is the core code automatically selected by China Telecom and China Netcom. Oh my God, it's amazing. It's actually implemented in js.

Explanation: There is a non-existent address in src, so when the two img are opened, an error will occur and the onerror event will be triggered. However, your browser has a way to load and judge the error of the two img. The order, and this order depends on how quickly your browser connects to the two URLs, which is reflected in the speed of http requesting the two domain names. If you are on the campus network or China Netcom, connect to www.jb51.net (this domain name is an IP bound to China Telecom) and cnc.jb51.net (this domain name is an IP bound to China Netcom)

Of course onerror="Javascript:top.location='http://cnc.jb51.net'" will be triggered first

This will open http://cnc.jb51.net

The same applies to telecommunications. In the end, campus network and Netcom users opened http://www.jb51.net/drect, while telecommunications users opened http://www.jb51.net/direct.
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