JavaScript click events not working on Samsung Galaxy SIII on Android 4.0.4 default browser - Stack Overflow

I have the strangest issue with the default browser of the Samsung Galaxy SIII on Android 4.0.4:With th

I have the strangest issue with the default browser of the Samsung Galaxy SIII on Android 4.0.4:

With the following page, clicking on the links will not trigger the JavaScript handlers. Removing a single 'a' letter from the content one of the divs makes them work again...

Here is a screenshot of the JS console:

I opened an android bug report, if you have the same issue please star it, thanks.

Thank you in advance for your help!

<html>
<head>
<script src=".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>

I have the strangest issue with the default browser of the Samsung Galaxy SIII on Android 4.0.4:

With the following page, clicking on the links will not trigger the JavaScript handlers. Removing a single 'a' letter from the content one of the divs makes them work again...

Here is a screenshot of the JS console:

I opened an android bug report, if you have the same issue please star it, thanks.

Thank you in advance for your help!

<html>
<head>
<script src="http://ajax.googleapis./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>
Share Improve this question edited Jul 17, 2012 at 13:25 Joel Arnold asked Jul 17, 2012 at 12:08 Joel ArnoldJoel Arnold 1,23114 silver badges28 bronze badges 9
  • Try $(element).on('blur', function(){}); – Mark Verkiel Commented Jul 17, 2012 at 12:14
  • @Pilatus I tried $("#blue").blur(function(e) {... but it doesn't work, did you try it with my example file? – Joel Arnold Commented Jul 17, 2012 at 12:22
  • This works fine on Galaxy Nexus Android 4.0.4 default browser. Have you tried looking at the console if the Galaxy SIII browser throws any errors? – Torsten Walter Commented Jul 17, 2012 at 12:34
  • @TorstenWalter When I click on a link I get: Uncaught TypeError: Cannot convert null to object – Joel Arnold Commented Jul 17, 2012 at 12:51
  • Actually I get the error at page load... – Joel Arnold Commented Jul 17, 2012 at 13:07
 |  Show 4 more ments

3 Answers 3

Reset to default 2

Actually there is at least an easy solution: change the id of the DIV to not contain the 'page' substring...

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. Found this thread. Changing from:

span id="page" 

to:

span id="pgNow" 

fixed it!

Something like this will work, too:

<a href='http://www.google.de' ontouchstart='window.location = this.href'>foo</a>"

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744274387a4566257.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信