首页 新闻 会员 周边 捐助

弹出层在IE和火狐中的兼容问题

0
悬赏园豆:10 [已解决问题] 解决于 2010-07-28 09:14

高手帮忙看看我写的这点代码为什么在Ie上面能弹出层,在火狐上就不可以弹出层了?

<style>

.lou{ z-index:auto; position:absolute; background-image:url(../images/g.png);text-align:center; width:175px; height:78px; background-repeat:no-repeat; }

.we{ border-bottom:1px solid #E1E1E1; margin-bottom:8px;}

.hei1{font-size:15px; font-family:"微软雅黑"; font-weight:bolder; }

</style>

 <script type="text/javascript">
        //弹层代码
        $(function() {
            var x;
            var y;
            var divStr = "";
            var a = $("a")
            //            $("a").mouseover(function() {
            $("a").hover(function() {
                divStr = "";
                $("#lou").remove();
                if (event.pageX == null && event.clientX != null) {
                    var doc = document.documentElement, body = document.body;
                    x = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
                    y = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
                    y = y - 300;
                    x = x - 50
                } //外侧if

                //鼠标点击楼时传入楼的Id
                var id = $(this).attr("id")
                $("#hidBuilId").val(id);
                $.ajax({
                    type: "post",
                    url: "homeHandler/XiaoquBuilding.ashx",
                    dataType: "json",
                    data: "CommId=<%=community.CommunityId %>," + $(this).attr("id"),
                    success: function(message) {
                        if (message != null) {
                            //                alert(x+","+y)
                            $.each(message.Building, function(i, item) {
                                divStr = "<div class=\"lou\" id=\"lou\" style=\"margin-left:" + x + "px; margin-top:" + y + "px; \" >";
                                divStr += "<ul> <li class=\"we\"><span class=\"hei1\">" + item.Id + "号</span> 入住用户" + item.ruzhu + " 还剩" + item.shengyu + "</li>"
                                divStr += "<li style=\"text-align:right;\"><img id=\"ruzhu\" src=\"<%=ruzhuImgUrl %>\" /> <img id=\"yezhu\"src=\"<%=yezhuImgUrl %>\"/></li>"
                                divStr += "</ul></div>"
                            });

                        } //内层if
                        $("#box").before(divStr);
                    }, //success
                    error: function(message) {
                        //alert(message);
                    }

                }); // ajax
            }); //hover 外层括号

            //移除弹出层
            $("a").hover(function() {
                divStr = "";
                $("#lou").remove();

            });


        });
   </script>

 


dream梦false的主页 dream梦false | 菜鸟二级 | 园豆:316
提问于:2010-07-26 09:34
< >
分享
最佳答案
0

是event.clientX的问题,请参考:ie和firefox中的event.clientX的区别

收获园豆:10
dudu | 高人七级 |园豆:30925 | 2010-07-26 11:06
其他回答(1)
0

其实要是代码写的规范  JS是最好的  未必JQUERY就在所有的浏览器都支持

洋哥 | 园豆:10 (初学一级) | 2010-11-29 13:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册