V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
3a3Mp112
V2EX  ›  iOS

iOS safari 上面的一个问题, mousedown 方法被拦截了。

  •  
  •   3a3Mp112 · Mar 3, 2018 · 1871 views
    This topic created in 2977 days ago, the information mentioned may be changed or developed.
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>js 计时</title>
    </head>
    <body>
    <input type="text" value="00:00">
    <p>
    <input type="button" value="长按开始计时 /松开暂停计时">
    <script>
    
        var oTxt=document.getElementsByTagName("input")[0];
        var oStart=document.getElementsByTagName("input")[1];
        var n= 0, timer=null;
        //开始计时
        oStart.onmousedown= function () {
            clearInterval(timer);
            timer=setInterval(function () {
                n++;
                var m=parseInt(n/60);
                var s=parseInt(n%60);
                oTxt.value=toDub(m)+":"+toDub(s);
            },1000/60);
        };
        //暂停计时
        oStart.onmouseup= function () {
            clearInterval(timer);
        }
        //补零
        function toDub(n){
            return n<10?"0"+n:""+n;
        }
    </script>
    </body>
    </html>
    

    在 iOS 的 safari 打开, 那个长按的 button, 长按的时候会弹出菜单。。。请教一下应该怎么解决?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   993 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:11 · PVG 03:11 · LAX 12:11 · JFK 15:11
    ♥ Do have faith in what you're doing.