The problem that the label href and onclick both exist in IE6

Source: Internet
Author: User
The problem that the label href and onclick both exist in IE6

Recently, a project (a Web page that displays weather forecasts) needs to use ajax to retrieve weather forecast data from the server.
After that, I tested IE7 on my computer and passed the test under ff2 and ff3.

After the launch, some colleagues failed to respond to the weather forecast and found that the browser was IE6. I immediately looked at the data with httpwatch and found that when I clicked the request under IE6, the returned status was aborted (that is, the request was interrupted ). Why ......

After several Google searches, I finally found the cause: the request link uses the tag, and the href and onclick events are simultaneously written on. For the link to tag a, when the user clicks the mouse, when object A is triggered, The onclick part is executed first, and then the href part is executed. If it is IE6, onclick is executed, send an HTTP request (the weather forecast requires asynchronous data requests ). Execute href instantly. Then IE6 will abort the previous request.

Solution: directly write The onclick event in href: href = "javascript: Do ()"
There is also a solution: <a href = "javascript: void (0)" onclick = "Do (); Return false;"> test </a>
In this way, the href part is ignored, which is useful for passing this through onclick or avoiding object.

 

 

From: http://www.cnblogs.com/phpliu/archive/2010/02/25/1673794.html

Recently, a project (a Web page that displays weather forecasts) needs to use ajax to retrieve weather forecast data from the server.
After that, I tested IE7 on my computer and passed the test under ff2 and ff3.

After the launch, some colleagues failed to respond to the weather forecast and found that the browser was IE6. I immediately looked at the data with httpwatch and found that when I clicked the request under IE6, the returned status was aborted (that is, the request was interrupted ). Why ......

After several Google searches, I finally found the cause: the request link uses the tag, and the href and onclick events are simultaneously written on. For the link to tag a, when the user clicks the mouse, when object A is triggered, The onclick part is executed first, and then the href part is executed. If it is IE6, onclick is executed, send an HTTP request (the weather forecast requires asynchronous data requests ). Execute href instantly. Then IE6 will abort the previous request.

Solution: directly write The onclick event in href: href = "javascript: Do ()"
There is also a solution: <a href = "javascript: void (0)" onclick = "Do (); Return false;"> test </a>
In this way, the href part is ignored, which is useful for passing this through onclick or avoiding object.

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.