简体   繁体   English

在Android 4.0.4默认浏览器上,JavaScript单击事件无法在Samsung Galaxy SIII上运行

[英]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.

相关问题 JS错误仅出现在春季三星Galaxy SIII上 - JS error appearing only on Spring Samsung Galaxy SIII phonegap android重定向到URL不适用于三星银河 - phonegap android redirect to url not working on samsung galaxy 在所有浏览器中单击“不适用于Nexus S ICS(4.0.4)的事件” - Click Events Not Working on Nexus S ICS (4.0.4) in All Browsers Javascript 在 Android 默认浏览器上不起作用 - Javascript Not Working on Android Default Browser PHP和javascript在Internet Explorer和Google Chrome上正常运行,但在Samsung Galaxy Android上运行不正常 - PHP and javascript working correctly on Internet Explorer and Google Chrome but not on Samsung Galaxy Android Android浏览器.click()无法使用javascript - Android Browser .click() not working javascript window.onunload在Samsung Galaxy Tab浏览器中不起作用 - window.onunload is not working in Samsung Galaxy Tab browser window.print()在常规浏览器中不起作用; 三星Galaxy Tab A - window.print() not working in stock browser; Samsung Galaxy Tab A 为什么Javascript无法在我的Samsung Internet浏览器上运行? 使用三星Galaxy S7 - Why does Javascript not work on my Samsung Internet Browser? Using Samsung Galaxy S7 requestFullscreen在Samsung移动默认浏览器中无法正常工作 - requestFullscreen not working properly in Samsung mobile default browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM