单击 Javascript 在 iOS 14 中不起作用 [英] Javascript on click not working in iOS 14

查看:45
本文介绍了单击 Javascript 在 iOS 14 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

答案在这里:

按钮 onclick 事件在 iOS 中不起作用,除非你离开应用程序然后返回,然后它起作用

OnClick 在 Ios11 上不起作用

iOS 上的 Safari9 不触发隐藏输入文件的点击事件

onclick 事件在 iphone 上不起作用

iOS 上未触发的点击事件

我如何使用 jQuery用于 iPhone 网络应用程序中的点击事件

jQuery 点击事件在 iOS 中不起作用

JavaScript OnClick 不适用于 iOS

让 onclick 在 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 :

<div id="replace1";><br><br><br><a class="btnxyspace";onClick="alert("sometext");">--><br><br><br>

这是 CSS :

@import url('https://fonts.googleapis.com/css?family=Montserrat:100,100i,300,300i,4 00,400i,700,700i,900,900i');* {字体系列:蒙特塞拉特;字体大小:14px;}.U3Gxm-butn {边框:1px 实心 #E77817;-webkit-border-radius: 15px;边框半径:15px;-webkit-box-sizing: 边框框;box-sizing: 边框框;填充:10px 5px;颜色:#E77817;光标:指针;背景:白色;边距:0 自动 10px;宽度:100%;/* 根据需要设置宽度 */显示:块;/* 使按钮出现在每个按钮下方 */向左飘浮;}.U3Gxm-butn:focus, .U3Gxm-butn:hover {背景:#E77817;大纲:0;颜色:#fff;}.actn 禁用{光标:不允许!重要;背景:#dddddd !重要;颜色:黑色!重要;指针事件:无;}.actn-选择{背景:#fba250 !重要;颜色:黑色!重要;}#加载{宽度:100%;高度:100%;顶部:0px;左:0px;位置:固定;显示:块;不透明度:0.7;背景色:#fff;z-索引:99;文本对齐:居中;}#加载图像{位置:绝对;最高:30%;左:40%;z-索引:100;}TD{自动换行:断字;}/* 下面类用于反对位置 */.xspace{位置:相对;顶部:20px;}.xspace:第一个字母{位置:相对;顶部:20px;文本转换:大写;}.xspacedown:第一个字母{填充底部:0%;文本转换:大写;}.xspaceop{位置:相对;顶部:50px;样式:溢出-x:自动;}.xyspace:第一个字母{文本转换:大写;}#replace1 >.xyspace{显示:内联块;}#replace1 >.xyspace:第一个字母{文本转换:大写;}.ntfnbkpjob1{游标:指针;}

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

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

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

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

任何人都可以提出在这种情况下有效的任何方法吗?

解决方案

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

我猜你在谈论这个,因为按钮被注释掉了.

I know the title is familiar, but the answers weren't !

The answers here :

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

didn't work for me, so before marking this question as duplicate, check my code :

THIS IS 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>

THIS IS THE 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;
}

I have created separate HTML and CSS files in my xCode project and this is how i am loading my html file in swift :

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

Have tried everything possible, changed CSS to cursor:pointer, did everything mentioned in these solutions, nothing seems to work.

These solutions might be relating to their problem. Every problem has different answer !

Can anyone suggest anything that works in this scenario ?

解决方案

<a class="btnxyspace" onClick="alert("sometext");"><input type="button" value="Hi"></a>

Shouldn't your on click look like this onClick="alert('sometext')" ?

I'm guessing you are talking about this one as button is commented out.

这篇关于单击 Javascript 在 iOS 14 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆