【问题标题】:Javascript on click not working in iOS 14点击时的Javascript在iOS 14中不起作用
【发布时间】:2021-03-15 11:47:44
【问题描述】:

我知道标题很熟悉,但答案却不是!

答案在这里:

Button onclick event not working in iOS unless you go away from app and back, then it works

OnClick not Working on Ios11

Safari on iOS 9 does not trigger click event on hidden input file

onclick event doesn't work on iphone

Click events not firing on iOS

How do I use jQuery for click event in iPhone web application

jQuery click events not working in iOS

JavaScript OnClick not working on iOS

Make onclick work on iphone

https://www.quirksmode.org/blog/archives/2010/10/click_event_del_1.html

https://www.quirksmode.org/blog/archives/2010/09/click_event_del.html

对我不起作用,所以在将此问题标记为重复之前,请检查我的代码:

这是 HTML:

<script>
    function showalert() {
        alert("I am an alert");
    }    
</script>
<div id="replace1" >
    
    <br><br><br>
    <a class="btnxyspace" onClick="alert("sometext");"><input type="button" value="Hi"></a>
<!--    <button value="HI" onclick = "showalert();">-->
    
    <br><br><br>
    
</div>

这是 CSS :

@import url('https://fonts.googleapis.com/css?family=Montserrat:100,100i,300,300i,4 00,400i,700,700i,900,900i');

* {
  font-family: Montserrat;
  font-size: 14px;
}

  .U3Gxm-butn {
    border: 1px solid #E77817;
    -webkit-border-radius: 15px;
    border-radius: 15px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: 10px 5px;
    color: #E77817;
    cursor: pointer;
    background:white;
    margin:0 auto 10px;
    width: 100%; /* Set a width if needed */
    display: block; /* Make the buttons appear below each */
float: left;
  }
  .U3Gxm-butn:focus, .U3Gxm-butn:hover {
    background: #E77817;
    outline: 0;
    color: #fff;
  }

.actn-disabled{
    cursor: not-allowed !important;
    background: #dddddd !important;
    color: black !important;
    pointer-events: none;
}

.actn-selected{
    background: #fba250 !important;
    color: black !important;
}

#loading 
{
    width: 100%;
    height: 100%;
    top: 0px;
    left: 0px;
    position: fixed;
    display: block;
    opacity: 0.7;
    background-color: #fff;
    z-index: 99;
    text-align: center;
}

#loading-image 
{
    position: absolute;
    top:30%;
    left: 40%;
    z-index: 100;
}



td { 
    word-wrap: break-word; 
} 




/* Below class use for op position */

.xspace{
    position: relative;
    top: 20px;
}

.xspace:first-letter{
    position: relative;
    top: 20px;
    text-transform: capitalize;
}

.xspacedown:first-letter{
    padding-bottom: 0%;
    text-transform: capitalize;
}

.xspaceop{
    position: relative;
    top: 50px;
    style:overflow-x:auto;
}

.xyspace:first-letter {
  text-transform: capitalize;
}

#replace1 > .xyspace{
    display:inline-block;
}

#replace1 > .xyspace:first-letter{
    text-transform: capitalize;
}

.ntfnbkpjob1{
    cursor:pointer;
}

我在我的 xCode 项目中创建了单独的 HTML 和 CSS 文件,这就是我在 swift 中加载我的 html 文件的方式:

let url = Bundle.main.url(forResource: "webview", withExtension: "html")
webView.loadFileURL(url!, allowingReadAccessTo: url!)

已经尝试了所有可能的方法,将 CSS 更改为 cursor:pointer,完成了这些解决方案中提到的所有操作,但似乎没有任何效果。

这些解决方案可能与他们的问题有关。 每个问题都有不同的答案!

任何人都可以提出任何适用于这种情况的建议吗?

【问题讨论】:

    标签: javascript ios xcode onclick wkwebview


    【解决方案1】:

    &lt;a class="btnxyspace" onClick="alert("sometext");"&gt;&lt;input type="button" value="Hi"&gt;&lt;/a&gt;

    您的点击不应该像这样onClick="alert('sometext')" 吗?

    我猜你说的是这个按钮被注释掉了。

    【讨论】:

    • onclick 或 onClick 不起作用。按钮被注释掉,因为它对任何一个都不起作用
    • 我认为 Najdan 是在谈论双引号内的双引号,而不是大写。
    • 你解决了吗?我最近遇到了类似的事情,发现了一个 2013 年的 hack,其中涉及添加一个空跨度,例如&lt;a class="btnxyspace" onClick="alert("sometext");"&gt;&lt;span&gt;&lt;/span&gt;&lt;input type="button" value="Hi"&gt;&lt;/a&gt;
    猜你喜欢
    • 1970-01-01
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-27
    • 1970-01-01
    • 1970-01-01
    • 2021-12-10
    相关资源
    最近更新 更多