首页 > 解决方案 > 在 iOS 中更改内容后,触摸保持在屏幕上

问题描述

我有这个简单的片段。它唯一要做的就是在用户触摸其中一个按钮后刷新内容:

<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="style-2.css">
    <link rel="stylesheet" type="text/css" href="responsive.css">
<script>
function init() {

    var content = "";
    var rand;
    
    for(var i=0; i<5; i++)
    {
        rand =  Math.floor(Math.random() * 10);
        content += "<a class=\"button\" id=\"" + rand + "\" onClick=\"init();\" href=\"#!\">" + rand + "</a>\n";
    }
    document.getElementById("choices").innerHTML = content;
}

function refreshcontent()
{
setTimeout(function(){ init()}, 900);
}

</script>
<meta charset="UTF-8">

</head>
    <body>
        <main>
            <body onload = "init();"/>
                <section id="services" class="white" >
                    <div id = "choices" >
                    </div>
            </section>
        </main>
    </body>
</html>

在 Android、PC 和 Mac 中,它运行良好。但是在我的 iPhone 中,无论我使用哪种浏览器,我触摸的按钮在内容重新加载后都会保持“按下”状态。

我通过触摸一个按钮然后立即触摸屏幕上的一些空白空间来测试它,然后它工作正常。

我错过了什么?

在此处输入图像描述 在此处输入图像描述

标签: javascripthtmliostouch

解决方案


推荐阅读