Event. cancelbubble = true cancel event processing

Source: Internet
Author: User

<Tr> <a href = "XXX"> connection </a> </tr>

In the preceding structure, when you click TR, the page is redirected to another page.

 
<Tr style = "cursor: Pointer" onmouseover = "this. style. backgroundcolor = 'ginsboro' "onmouseout =" this. style. backgroundcolor = ''" onclick = "Return click ();">

 

 
Function click () {window. Location. href = "XXX ";}

 

<A href = "XXX"> connection </a> can be changed to <a href = "XXX" onclick = "event. cancelbubble = true"> connection </a>

This avoids clicking the label and redirecting to another page. Onclick = "event. cancelbubble = true" cancel event processing.

Otherwise, when you click a, the system will jump to another page.

Resolution:

Cancel event bubbling. In the event mechanism of IE, the trigger event will be uploaded step by step from the child element to the parent element, that is, if the child element triggers the click event, the parent element click event is also triggered. cancelbubble = true; stop the upload

In addition, the IE event is passed from bottom to top:

Event source object-> upper-level object->...-> body-> document-> window

NS event transmission is from top to bottom:

Window-> document-> body->...-> event source object

(Event. returnvalue = false sets the event return value to false, that is, cancel event processing)

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.