Mobile development Those hole--safari mobile Click event bubbling Bug

Source: Internet
Author: User

Test this piece of code on Iphone6 plus Safari today:

<Script>$ (document). On ('Click','. Callapp', function() {alert ("hehe"); })</Script><Divclass= "Callapp camiddle">Open the app and join the event now</Div><ahref= "javascript:;"class= "Callapp camiddle">Open the app and join the event now</a><imgsrc= "Http://news.baidu.com/resource/img/logo_news.gif"alt= "Test"class= "Callapp">

found that clicking on and <a> can trigger the event, but clicking <div> is not valid.

1. At first, I thought it was a quoted Zepto problem, and later after using jquery, it was the same performance, and neither the PC nor the Android device was a problem, except that iOS safari could not trigger the event.

2. After I change the click event to Touchstart, the event can be triggered again.

Weird.

3. Is event agent Safari not supported? I tried to get rid of the agent direct registration event, test found, OK.

4. Then, I delegate the event to one of the div containers below the body to continue the test and find it OK.

5. Did the Safari event bubble and didn't come up with the document? Test the following section of code:

Document.addeventlistener ("click",function(e) {    alert (e.target.tagname)},false)

5. Sure enough, the same as the beginning of the phenomenon, click and <a> can be triggered, click <div> Invalid

6.google a bit, sure enough this evil safari is a bug, my English is not good, we can go to see this http://www.quirksmode.org/blog/archives/2010/10/click_event_del_1.html

Solution Solutions

1. Add Style body{cursor:pointer}--I don't know why, see http://stackoverflow.com/questions/10165141/.

2. Using Zepto.js's 1.0RC1 version of the tap event-without looking closely at the document, I tested the v1.0-1.1.6 and so on that these versions are not good enough to make

3. Welcome to the Exchange

Mobile development Those hole--safari mobile Click event bubbling Bug

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.