"Mobile" JS prohibit page swipe and allow sliding

Source: Internet
Author: User

Disable page swipe

Normally stationary slide scheme: (Block sliding events)

window.ontouchmove=function(e) {    && e.preventdefault ();    E.returnvalue=false;     && e.stoppropagation ();     return false ;};

Some models do not support the above static sliding scheme, can be used: (click on the page floating to the specified position does not move the body of the position set to fixed)

$ ("#btn"). Click (function() {    var top=$ (window). scrolltop ();   This is the current scrolling page scroll bar position    $ ("Body"). css ({        "position": "Fixed",        "width": "100 % ",        // where current needs to be fixed     );});
Allow page swipe:

Generally allows sliding scheme: (Empty slide event)

Window.ontouchmove= "";

To handle the permissible sliding of a part of the model to prohibit sliding: (set body position to static)

$ ("#btn2"). Click (function() {    $ ("Body"). css ({        "position": "Static"    }) ;});

"Mobile" JS prohibit page swipe and allow sliding

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.