In regular safari my script changes the url of the page window.history.pushState and that works just fine but in ios, somehow the URL that gets loaded it that of the last page... It is really frustrating! is this a bug?
Thanks for your help :)
here is the code:
    function hijackLinks() {
        $('a').live("click", function (e) {
            e.preventDefault();
            loadPage(e.target.href);            
            $(this).addClass('click');
        });
        if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {$('a').live("touchstart", function (e) {
             direction = $(this).attr('class');
            $(this).addClass('temp');
             setTimeout(function () {
                    $('.temp').addClass('click');
                }, 100);
        });
        $('a').live("touchmove", function (e) {
            $('.temp').removeClass('temp');
            setTimeout(function () {
                    $('.click').removeClass('click');
                }, 1);})
            $('.click').live("touchend", function (e) {开发者_如何学C
             setTimeout(function () {
                    $('.click').removeClass('click');
                }, 1);})}
                else{
         $('a').live("mouseenter", function (e) {
            direction = $(this).attr('class');
             $(this).addClass('click');})
              $('a').live("mouseleave", function (e) {
             $(this).removeClass('click');})
                }
    }
    function loadPage(url) {
        if (url === undefined) {
            $('body').load('url', 'header:first,#content,footer', hijackLinks);
        } else {
            $.get(url, function (data) {
                $('body').append(data);
                sm = $(window).width();
                sn = $(window).scrollTop();
             window.scrollTo(0,0);
             window.history.pushState(null, null, url);
                if (direction === "leftnav") {
                    $('body>header:last,body>#content:last,footer:last').css("-webkit-transform", "translate( -" + sm + "px,0px)");
                    footerheight = $('body>#content:last').outerHeight(false) + $('body>header:last').outerHeight(true);
                    $('footer:last').css("top", footerheight);
                    $('body>header,body>#content,footer').css("-webkit-transition-duration", "0.5s");
                    $('body>header:first,body>#content:first,footer:first').css("-webkit-transform", "translate(" + sm + "px,0px)");
                    $('body>header:last,body>#content:last,footer:last').css({"-webkit-transform": "translate(0,0)"});
                }
                if (direction !== "leftnav") {
                    $('body>header:last,body>#content:last,footer:last').css("-webkit-transform", "translate(" + sm + "px,0px)");
                    footerheight = $('body>#content:last').outerHeight(false) + $('body>header:last').outerHeight(true);
                    $('footer:last').css("top", footerheight);
                    $('body>header,body>#content,footer').css("-webkit-transition-duration", "0.5s");
                    $('body>header:first,body>#content:first,footer:first').css("-webkit-transform", "translate( -" + sm + "px,0px)");
                    $('body>header:last,body>#content:last,footer:last').css("-webkit-transform", "translate(0,0)");
                }
                setTimeout(function () {
                    $('body>header:not(:last),body>footer:not(:last),body>#content:not(:last)').remove();
                    $('body>header,body>footer,body>#content').removeAttr('style');
                },1000);
            });
        }
    }
    $(document).ready(function () {
        loadPage();
    });
    window.addEventListener("popstate", function(e) {
    loadPage(location.pathname);
});
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论