Add an event to a in IE6. If an HTTP request exists in the event, it will be invalid.

Source: Internet
Author: User

Problem: When the verification code is displayed in the login box, an operation is usually performed. Click "a" to display the verification code. The approximate structure is as follows:

 <  IMG  ID  = "Img1"   />  <  A  ID  = "A1"  Href  = "Javascript: void (0 )"  > Click Show Verification Code </  A  >  < Script  >  A1.onclick  =  Function  (){  //  Click A1, request the Verification Code address, and display  Img1.src  =  '  Http ://....... '  ;}  </  Script  > 

If yourCodeIn IE6, the request will fail.

Why? Unknown. However, we can conclude that this is the question of this article. If you add an event function to tag a, the HTTP request in the event function fails.

Solution. Block default events.

 <  IMG  ID  = "Img1"   />  <  A  ID = "A1"  Href  = "Javascript: void (0 )"  > Click Show Verification Code </  A  >  <  Script  >  A1.onclick  =  Function  (){ //  1 event. returnvalue = false;  Img1.src  =  '  Http ://.......  '  ;  //  2 Return false;  }  </ Script  > 

You can solve this problem in any of the above annotations.

I guess the cause is that it is estimated that the redirection event of default A is not blocked, and IE6 thinks it is necessary to jump to the page. At this time, requests in the page are blocked.

Summary:
Add return false to the end of an event to a later;

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.