V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
3a3Mp112
V2EX  ›  iOS

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

  •  
  •   3a3Mp112 · 2018-03-03 22:54:36 +08:00 · 1551 次点击
    这是一个创建于 2257 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <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, 长按的时候会弹出菜单。。。请教一下应该怎么解决?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1048 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:13 · PVG 04:13 · LAX 13:13 · JFK 16:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.