Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 然后,您可以尝试打开“开发人员栏”上的设置以查看更多详细信息。希望能有帮助。@jirapong,谢谢。我用了这个:nevermind我用了这个:document.ontouchmove=function(e){e.preventDefault();}这也会_Javascript_Iphone_Scroll - Fatal编程技术网

Javascript 然后,您可以尝试打开“开发人员栏”上的设置以查看更多详细信息。希望能有帮助。@jirapong,谢谢。我用了这个:nevermind我用了这个:document.ontouchmove=function(e){e.preventDefault();}这也会

Javascript 然后,您可以尝试打开“开发人员栏”上的设置以查看更多详细信息。希望能有帮助。@jirapong,谢谢。我用了这个:nevermind我用了这个:document.ontouchmove=function(e){e.preventDefault();}这也会,javascript,iphone,scroll,Javascript,Iphone,Scroll,然后,您可以尝试打开“开发人员栏”上的设置以查看更多详细信息。希望能有帮助。@jirapong,谢谢。我用了这个:nevermind我用了这个:document.ontouchmove=function(e){e.preventDefault();}这也会杀死所有点击事件,所以页面上没有任何内容是可点击的。肯德尔,你介意添加更多的代码吗,这样我就可以看到发生了什么。。。我对这一点还很陌生-这里有一些不起作用的东西:document.body.addEventListener('touchmove


然后,您可以尝试打开“开发人员栏”上的设置以查看更多详细信息。希望能有帮助。@jirapong,谢谢。我用了这个:nevermind我用了这个:
document.ontouchmove=function(e){e.preventDefault();}
这也会杀死所有点击事件,所以页面上没有任何内容是可点击的。肯德尔,你介意添加更多的代码吗,这样我就可以看到发生了什么。。。我对这一点还很陌生-这里有一些不起作用的东西:
document.body.addEventListener('touchmove',function(e){e.preventDefault();});document.body.addEventListener('touchstart',函数(e){e.preventDefault();})
nevermind我使用了这个:
document.ontouchmove=function(e){e.preventDefault();}
bit.ly链接不起作用。你有原始的URL吗?链接是。如果自定义域上的bit.ly链接停止工作,只需将域更改为bit.ly(此链接变为)。如果您已执行此操作,是否有方法启用“donotscrollme”子元素上的滚动?问得好。你可以试试$(“scrollme”)。在(“touchmove”,true);-不确定这是否有效。@Pirkka Esko-您可以试试
$(elem.removeClass('donotscrollme')
@PirkkaEsko您可以在(“touchmove”,false)上尝试$(“父/子”);先生,你该喝杯啤酒!第二个代码片段对我来说非常有用。谢谢如果你真的能把它包装成一个可使用的拷贝和粘贴,那么就可以使用功能了。嗯,它似乎完全阻止了它,这意味着没有任何东西会显示出
firstmove
方法在iOS 13上不再起作用了。所有元素现在都被阻止滚动。这已经有一段时间了,但这个答案似乎并不适用于这个问题,因为它描述了如何避免在本机iOS应用程序的滚动视图中滚动。
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
document.ontouchstart = function(e){ 
    e.preventDefault(); 
}
<script type="text/javascript">
   function blockMove() {
      event.preventDefault() ;
}
</script>

<body ontouchmove="blockMove()">
$("donotscrollme").on("touchmove", false);
document.ontouchmove = function(e){ 
    e.preventDefault(); 
}
document.ontouchstart = function(e){ e.preventDefault(); }
document.ontouchstart = function(e){ return true; }
document.addEventListener('touchstart', function (e) {
    e.preventDefault();
});
var firstMove;

window.addEventListener('touchstart', function (e) {
    firstMove = true;
});

window.addEventListener('touchmove', function (e) {
    if (firstMove) {
        e.preventDefault();

        firstMove = false;
    }
});
var touchTarget,
    touchScreenX,
    touchScreenY,
    conditionParentUntilTrue,
    disableScroll,
    scrollMap;

conditionParentUntilTrue = function (element, condition) {
    var outcome;

    if (element === document.body) {
        return false;
    }

    outcome = condition(element);

    if (outcome) {
        return true;
    } else {
        return conditionParentUntilTrue(element.parentNode, condition);
    }
};

window.addEventListener('touchstart', function (e) {
    touchTarget = e.targetTouches[0].target;
    // a boolean map indicating if the element (or either of element parents, excluding the document.body) can be scrolled to the X direction.
    scrollMap = {}

    scrollMap.left = conditionParentUntilTrue(touchTarget, function (element) {
        return element.scrollLeft > 0;
    });

    scrollMap.top = conditionParentUntilTrue(touchTarget, function (element) {
        return element.scrollTop > 0;
    });

    scrollMap.right = conditionParentUntilTrue(touchTarget, function (element) {
        return element.scrollWidth > element.clientWidth &&
               element.scrollWidth - element.clientWidth > element.scrollLeft;
    });

    scrollMap.bottom =conditionParentUntilTrue(touchTarget, function (element) {
        return element.scrollHeight > element.clientHeight &&
               element.scrollHeight - element.clientHeight > element.scrollTop;
    });

    touchScreenX = e.targetTouches[0].screenX;
    touchScreenY = e.targetTouches[0].screenY;
    disableScroll = false;
});

window.addEventListener('touchmove', function (e) {
    var moveScreenX,
        moveScreenY;

    if (disableScroll) {
        e.preventDefault();

        return;
    }

    moveScreenX = e.targetTouches[0].screenX;
    moveScreenY = e.targetTouches[0].screenY;

    if (
        moveScreenX > touchScreenX && scrollMap.left ||
        moveScreenY < touchScreenY && scrollMap.bottom ||
        moveScreenX < touchScreenX && scrollMap.right ||
        moveScreenY > touchScreenY && scrollMap.top
    ) {
        // You are scrolling either the element or its parent.
        // This will not affect document.body scroll.
    } else {
        // This will affect document.body scroll.

        e.preventDefault();

        disableScroll = true;
    }
});
body {

height: 100%;
overflow: hidden;
width: 100%;
position: fixed;
}