如何解决ipad air上的javascript点击问题

时间:2014-02-16 16:21:53

标签: javascript jquery ios ipad air

我的网站上有一个菜单,上面有这个html:

<div class="final_dates_container">
            <table border="0" class="skormix_date_table">
                <tr>

                    <td>
                        <ul id="dates_list" class="final_dates_list">
                            <li class='skormix_dates'  id='current'>&#x25BC;&nbsp;&nbsp;<script>document.write(now);</script></li>
                            <li class='skormix_dates'  id='-6' style='display:none'><script>document.write(prev5);</script></li>
                            <li class='skormix_dates'  id='-5' style='display:none'><script>document.write(prev4);</script></li>
                            <li class='skormix_dates'  id='-4' style='display:none'><script>document.write(prev3);</script></li>
                            <li class='skormix_dates'  id='-3' style='display:none'><script>document.write(prev2);</script></li>
                            <li class='skormix_dates'  id='-2' style='display:none'><script>document.write(prev1);</script></li>
                            <li class='skormix_dates'  id='-1' style='display:none'><script>document.write(prev0);</script></li>
                            <li class='skormix_dates'  id='0' style='display:none'><script>document.write(now);</script></li>
                            <li class='skormix_dates'  id='1' style='display:none'><script>document.write(next0);</script></li>
                            <li class='skormix_dates'  id='2' style='display:none'><script>document.write(next1);</script></li>
                            <li class='skormix_dates'  id='3' style='display:none'><script>document.write(next2);</script></li>
                            <li class='skormix_dates'  id='4' style='display:none'><script>document.write(next3);</script></li>
                            <li class='skormix_dates'  id='5' style='display:none'><script>document.write(next4);</script></li>
                            <li class='skormix_dates'  id='6' style='display:none'><script>document.write(next5);</script></li>
                        </ul>
                    </td>
                </tr>
            </table>
        </div>

它在网站上工作正常,但在我的ipad上根本无法正常工作。当我点击菜单时根本没有发生任何事情。 我想知道问题是什么。我应该做什么或添加任何特殊的ipad? javascript是否与平板电脑存在兼容性问题。 这是js代码:

//this part is to handle the list of dates choosing and get data of a date
$(document).ready(function(){
    $('.final_dates_list li').live('click',function(){

        id = $(this).attr("id");//alert(id);
        value = $(this).html();//alert(value);
        value = value.replace("&#x25BC;&nbsp;&nbsp;","");//alert(value);
        //value = value.replace("▼;&nbsp;&nbsp;","");   alert(value);
        temp = value.split("</script>");//alert(temp[1]);
        if(typeof temp[1] == 'undefined')
        {
            temp[1] = value;
        }
        //alert(temp[1]);
        if(id == 'current')
        {

            $("#dates_list").find("li").each(function(){
                //alert($(this).attr("id"));
                value1 = $(this).html();//alert(value1);
                temp1 = value1.split("</script>");  
                //alert(temp[1]);
                //alert(temp1[1]);
                if(typeof temp1[1] == 'undefined')
                {//alert('1');alert(value1);alert(temp1[1]);
                    //temp1[1] = value1.replace("&#x25BC;&nbsp;&nbsp;","");//alert(temp1[1]);
                }   
                temp[1] = temp[1].replace("▼&nbsp;&nbsp;","");
                //alert(temp[1]);alert(temp1[1]);   
                if(String(temp[1]) == String(temp1[1]) )
                {//alert('yes');
                    $(this).css({"background-color":"#00cc00"});
                }
                else
                { //alert('no');
                    $(this).css({"background-color":"#2c2c2c"});
                }
                //$(this).show();

                if(Number(sessionStorage.dates_list_status) == 0)
                {
                    $(this).slideDown('slow');
                }
                else if(Number(sessionStorage.dates_list_status) == 1)
                {
                    $(this).slideUp('slow');
                }
            });
            $(this).css({"background-color":"#00cc00"});
            $("#dates_list").find("#current").slideDown('slow');
            if(Number(sessionStorage.dates_list_status) == 0)
            {
                sessionStorage.dates_list_status = Number(sessionStorage.dates_list_status) +1 ;
            }
            else
            {
                sessionStorage.dates_list_status = Number(sessionStorage.dates_list_status) -1 ;
            }

        }
        else
        {
            if(id == '-6')
            {
                $(".final_dates_container").find("#left_button").hide();
                $(".final_dates_container").find("#left_button_mask").show();
                $(".final_dates_container").find("#right_button").show();
            }
            else if(id == '6')
            {
                $(".final_dates_container").find("#right_button").hide();
                $(".final_dates_container").find("#left_button").show();
                $(".final_dates_container").find("#left_button_mask").hide();
            }
            else if(id == '0')
            {
                $(".final_dates_container").find("#left_button").show();
                $(".final_dates_container").find("#left_button_mask").hide();
                $(".final_dates_container").find("#right_button").show();

            }
            else
            {
                $(".final_dates_container").find("#left_button").show();
                $(".final_dates_container").find("#left_button_mask").hide();
                $(".final_dates_container").find("#right_button").show();
            }
            if(Number(sessionStorage.dates_list_status) == 0)
            {
                sessionStorage.dates_list_status = Number(sessionStorage.dates_list_status) +1 ;
            }
            else
            {
                sessionStorage.dates_list_status = Number(sessionStorage.dates_list_status) -1 ;
            }
            //to show a mask over the page this will prevent the dates buttons from being pressed until the data is loaded
            mask_width = $(document).find('.body_table').css('width');
            mask_height = $(document).height();
            get = $(document).find('.mask');
            $(get).show();
            $(get).css({"height":mask_height,"width": mask_width});

            this_id = $(this).attr("id");
            value = $(this).html();
            temp = value.split("</script>");
            temp_temp = '&#x25BC;&nbsp;&nbsp;'+temp[1];
            $("#current").html(temp_temp); 
            sessionStorage.skormix_date = this_id;
            $("#dates_list").find("li").each(function(){
                //alert($(this).attr("id"));
                //$(this).hide();
                $(this).slideUp('slow');
            });
            $("#dates_list").find("#current").slideDown('slow');
        }
    });
}); 

0 个答案:

没有答案