Clever Use of IMG's onerror event to deal with China Netcom's North-South branches

Source: Internet
Author: User
Background:
China Telecom Netcom's North-South splitting has become an unchangeable situation. As our website friends know, if we want to allow our friends in North and South regions to access our website smoothly, we need to buy dual-line servers, it is the line that connects both the Netcom user and the telecom user, although some data centers provide two IP Address (China Netcom and China Telecom have one IP At this time, we need to map a telecom address and a Netcom address during domain name ing, for example: Dianxin.xxx.com; wangtong.xxx.com; However, users always want to access Www.xxx.com In other words, we need to access Www.xxx.com When the user intelligently determines whether the user is in the north or south, and then jumps.

Ideas:
In www.xxx.com, let the client sendDianxin.xxx.comAndWangtong.xxx.comIf an incorrect request is sent, which address returns an incorrect response speed indicates the address that the user should access.

KeyCode:
Onerror = "location. Top. url = 'HTTP: // dianxin.xxx.com/'"/>
Onerror = "location. Top. url = 'HTTP: // wangtong.xxx.com/'"/>

In order for the user to directly jump to a faster line during the next visit, we can save the result of this judgmentCookie.

IMGOfOnerrorAnother application of the event:
We do not want users to see invalid images on our website. Even if an invalid image is displayed, we hope to tell users that the image is invalid in a friendly way, instead of showing users the default Red Cross directly. What should we do?OnerrorIn the eventSRCSet the property to an existing image on our website that does not exist.
Sample Code:
Onerror = "This. src = 'HTTP: // www.xxx.com/inv).gif'"/>

Note:
There are many solutions for north-south splitting. This article only provides you with one idea.

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.