验证功能在IE中没问题,在火狐浏览器中无反应

一个投票的验证功能,验证是否是重复投票功能.

 源代码:<table border="0" align="center" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td>
                                                            <strong>推介此食评</strong>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                         <a onclick='RecommendRating(<%#Eval("ReviewID")%>,this.parentNode.getElementsByTagName("SPAN").item(0))'>
                                                            <img src="images/btn_RecommendReview.gif" alt="推介" title="推介" style="cursor: pointer" /></a><br />
                                                            <asp:Label ID="lblrecommend" runat="server"><%#Eval("RecommendedCount")%></asp:Label>
                                                            个
                                                           
                                                        </td>
                                                    </tr>
                                                </table>

上面是点击投票的代码,用<asp:Label ID="lblrecommend 记录票数, 在IE中成功后,数字会变化,在火狐中无反应

JS:

<script type="text/javascript" >

        function RecommendRating(reviewid, lblrec) {
       
            if (getCookie('rating' + reviewid)) { alert('不能重复推介食评'); return; }
            var oBao;
          
            if (window.ActiveXObject) {
                oBao = new ActiveXObject("Microsoft.XMLHTTP");
            }
            else if (window.XMLHttpRequest) {
                oBao = new window.XMLHttpRequest();
            }

            oBao.open("Get", "ReviewRecommedService.aspx?ReviewId=" + reviewid, false);
            oBao.send(null);
   
            var strResult = oBao.responseText;
            if (strResult != 0) {

                if (navigator.appName.indexOf("Explorer") > -1) {
                    lblrec.outerText = strResult;
                } else {
                    lblrec.textContent = strResult;
                }
              setCookie('rating' + reviewid, reviewid, 1);
            }
            else

                window.alert(strResult);
        }
      </script>

 

这时验证的JS代码,其中我省略中验证页面中的功能和记录cookie功能. 只有上述提到问题的功能. 蓝色部分是用来分辨IE还是火狐浏览器,分别实例不同的对象,然后调用投票功能.

绿色部分是返回结果后,针对IE和火狐浏览器对<asp:Lable>不同赋值方法.

区别在于,在IE中,lblrec.outerText  而在火狐中是使用lblrec.textContent ,不然在火狐中数字不会变化,需要刷新页面才可以看到新的数字.

 www.aitaowang8.com

posted @ 2012-03-09 12:25  jake2011  阅读(340)  评论(0编辑  收藏  举报