[英]JavaScript click events not working on Samsung Galaxy SIII on Android 4.0.4 default browser
I have the strangest issue with the default browser of the Samsung Galaxy SIII on Android 4.0.4: 我对Android 4.0.4上三星Galaxy SIII的默认浏览器有一个最奇怪的问题:
With the following page, clicking on the links will not trigger the JavaScript handlers. 在下面的页面中,单击链接不会触发JavaScript处理程序。 Removing a single 'a' letter from the content one of the divs makes them work again... 从其中一个div中删除一个'a'字母使它们再次工作......
Here is a screenshot of the JS console: 这是JS控制台的屏幕截图:
I opened an android bug report , if you have the same issue please star it, thanks. 我打开了一个android bug报告 ,如果你有同样的问题,请给它明星,谢谢。
Thank you in advance for your help! 预先感谢您的帮助!
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
alert('attaching click handlers');
$("#red").click(function(e) {
alert('red clicked');
$("body").css("background-color", "#CC0000");
});
$("#green").click(function(e) {
alert('green clicked');
$("body").css("background-color", "#00CC00");
});
$("#blue").click(function(e) {
alert('blue clicked');
$("body").css("background-color", "#0000CC");
});
});
</script>
</head>
<body>
<div>
<p>
<a id="red" href="#">CHANGE TO RED</a>
</p>
<p>
<a id="green" href="#">CHANGE TO GREEN</a>
</p>
<p>
<a id="blue" href="#">CHANGE TO BLUE</a>
</p>
</div>
<p>Removing one of the a's in the content below will make the JS
click events work (i.e. trigger background color change), and
so will changing the 'page' class or id into something else</p>
<div class="page" id="page">
<div>aaaaaaaaaaaaaaaaaaa</div>
<ul>
<li>
<div>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
</li>
</ul>
</div>
</body>
</html>
Actually there is at least an easy solution: change the id of the DIV to not contain the 'page' substring... 实际上至少有一个简单的解决方案:改变DIV的id不包含'page'子串...
It is more a workaround than a solution but what else can be done if the browser has a buggy customization? 它更像是一种解决方法而不是一种解决方案,但如果浏览器有错误的定制,还能做些什么呢?
I just had a similar problem on a Samsung Galaxy. 我在三星Galaxy上遇到了类似的问题。 Found this thread. 找到了这个帖子。 Changing from: 改变自:
span id="page"
to: 至:
span id="pgNow"
fixed it! 固定它!
这样的东西也会起作用:
<a href='http://www.google.de' ontouchstart='window.location = this.href'>foo</a>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.