禁止微信自带下拉,然后内部的内容可以滚动。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

</head>
<body>
<button id="pastePull">点击</button>
<div id="d">123</div>
<div class="div" id="div">
    <!--<iframe id="iframe1" name="iframe" height="500" width="100%" style="width: 100%;height: 100%;overflow: auto" src='http://player.youku.com/embed/XNDE4NzA4MzkzNg==' frameborder=0 ></iframe>-->

    <div class="iframeHove"  id="iframeHove" style="opacity: 0.5"><span>浏览</span></div>
</div>

<style>
    .div{
        width: 510px;
        height: 500px;
        position: absolute;
        top: 100px;
        overflow: auto;
        left: 100px;
        background: red;
    }
    .iframeHove{
        width: 120px;
        height: 700px;
        background-color: darkblue;
        border-radius: 6px;
        line-height: 48px;
        font-size: 18px;
        text-align: center;
        position: absolute;
        color: white;
        top: 0px;
        left: 100px;
        transform: scale(1);
        transform-origin: 0 0;
        /*-webkit-transform: ;*/
    }
    .iframeHove span{
        opacity: 0.7;
    }
    .iframeHove span:hover{
        opacity: 1;
    }
</style>
<script>

        document.addEventListener('touchmove',scrollFunc,{passive: false});
        document.getElementById("iframeHove").addEventListener('touchstart',function (e) {
            _y=e.touches[0].pageY;
        })
            document.getElementById("iframeHove").addEventListener('touchmove',function (e) {


            if(document.body.scrollTop<0){
                e.preventDefault();

            }else{
               if(document.body.scrollTop===0){
                   if(document.getElementById("div").scrollTop===200){ //内部内容滑动的最大值
                       if(e.touches[0].pageY>_y){
                           e.stopPropagation()

                       }

                   }else {
                       if(e.touches[0].pageY<_y){
                           e.stopPropagation()

                       }
                       if(document.getElementById("div").scrollTop>0){
                           e.stopPropagation()

                       }

                   }



               }else{
                   e.stopPropagation()

               }


            }
            document.getElementById("d").innerText=document.getElementById("div").scrollTop;

        },{passive: false});


    function scrollFunc(e) {
       // console.log("111")
e.preventDefault()
e.stopPropagation()
    }


</script>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值