3a3Mp112
V2EX  ›  iOS

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

  •  
  •   3a3Mp112 · Mar 3, 2018 · 1905 views
    This topic created in 2998 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   ·   5277 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:45 · PVG 16:45 · LAX 01:45 · JFK 04:45
    ♥ Do have faith in what you're doing.