本文介绍了不工作的三星Galaxy SIII在Android 4.0.4默认浏览器的JavaScript单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有奇怪的问题,与三星Galaxy SIII的在Android 4.0.4的默认浏览器:

通过下面的页面,点击链接将不会触发JavaScript的处理程序。从申报单的人让他们再次合作的内容删除一个A字母...

下面是JS控制台的屏幕截图:

我开了一个 Android的bug报告,如果你有同样的问题,请明星吧,谢谢。

感谢您在您的帮助!

 < HTML>
< HEAD>
<脚本SRC =htt​​p://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js类型=文/ JavaScript的>< / SCRIPT>
<脚本类型=文/ JavaScript的>
    $(文件)。就绪(函数(){
        警报(附加单击处理');
        $(#红)。点击(函数(五){
            警报(红色点击);
            $(机构)的CSS(背景色,#CC0000)。
        });
        $(#绿色)。点击(函数(五){
            警报('绿点击);
            $(机构)的CSS(背景色,#00CC00)。
        });
        $(#蓝色)。点击(函数(五){
            警报(蓝色点击);
            $(机构)的CSS(背景色,#0000CC);
        });
    });
< / SCRIPT>
< /头>
<身体GT;
    < D​​IV>
        &其中p为H.;
            <一个ID =红的href =#>变为红色< / A>
        &所述; / P>
        &其中p为H.;
            <一个ID =绿色的href =#>变为绿色< / A>
        &所述; / P>
        &其中p为H.;
            <一个ID =蓝的href =#>变为蓝色< / A>
        &所述; / P>
    < / DIV>
    &其中p为H.;在内容卸下一个的之一以下将使JS
        单击事件工作(即触发背景颜色变化),和
        因此将改变页class和id到别的< / P>
    < D​​IV CLASS =页面ID =页面>
        < D​​IV> aaaaaaaaaaaaaaaaaaa< / DIV>
        < UL>
            <李>
                <div>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
            &LT; /李&GT;
        &LT; / UL&GT;
    &LT; / DIV&GT;
&LT; /身体GT;
&LT; / HTML&GT;
 

解决方案

其实至少有一个简单的解决方案:改变DIV的ID不包含在页面子......

这更是一个解决方法不是一个解决方案,但还有什么可以,如果浏览器有一个越野车的定制做?

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.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...

It is more a workaround than a solution but what else can be done if the browser has a buggy customization?

这篇关于不工作的三星Galaxy SIII在Android 4.0.4默认浏览器的JavaScript单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 08:37