Solve Iscroll hyperlink open problem with JavaScript

Source: Internet
Author: User

When using Iscroll on mobile, the touch event binding is enabled by default and is sensitive to touch events. If the finger touches the connection, the browser will open the connection operation by default if the slide is not finished. This will not complete the normal scrolling.

Iscroll design idea is in a page completes the operation, does not have the new opening tab to open the page the way, then both uses Iscroll and realizes the new page to open function how to do?

The time.qq.com approach is that the entire page does not use a tag, and is completely converted using a script-manipulation interface.

http://h5.m.sohu.com/'s approach is to use a and HREF,HREF values that are hashed and will not cause new pages to open

http://ipad.hao123.com/#index is handled in a very special way, using the dataset API and window.open

<a ontouchmove= "This.s=1" ontouchend= "THIS.S | | window.open (this.dataset.href), this.s=0 "target=" _blank "data-href=" "Http://www.hao123.com/topic/pig" > The Mystery of the Dead pig in Huangpu River </a>

Check the scrolling state to determine whether the connection is turned on when a flag,touchend is triggered when Touchmove is fired. This avoids the misoperation caused by scrolling and enables you to open a new page.

Author: cnblogs Small Jade Watermelon

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/

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.