当你在iPhone上“将网站添加到主屏幕”时,Ajax会中断

时间:2013-08-20 02:15:57

标签: javascript jquery iphone web-applications mobile-safari

我有一个网站使用ajax在用户点击按钮时引入内容。除非有人使用移动Safari的“添加到主屏幕”功能,然后使用主屏幕上的图标打开网站,否则此工作正常。

当有人从主屏幕图标打开网站时,它一直有效,直到ajax加载部分。当有人点击链接时,屏幕闪烁白色然后加载内容,但是在加载功能中应该运行的任何功能都没有实际运行。就像内容被加载一样但是应该发生的动画不会发生,并且页面看起来很破碎。

这是一个奇怪的问题,我无法检查问题,因为我无法访问我的控制台。

以下是我的网络应用程序的链接(尚未完成) - http://chrisgjones.com/aut/1.3/

我的ajax加载看起来像这样

<div class="inner">
     <a href="farm.html">Link</a>
</div>

function loadProject(){

        var $load = $('#level');

        $(document).on('click','.inner a',function(e){          

            e.preventDefault();
            $this = $(this);

            var _sourceTarget = '#puzzle',
                _url= $this.attr('href');

                $load.load(_url+" "+_sourceTarget, function(){

                    animalSlider();

                    setTimeout(function(){ 
                        $('.animal-content').centerRelative();
                    }, 2000);

                    $('#level-selection').animate({'left':'-200%'}, _speed, _ease, function(){

                        $logo.animate({'top':'10%'}, _speed, _ease);
                        $loader.animate({'margin-bottom':'10px'}, _speed, _ease, function(){

                            setTimeout(function(){ 

                                $logo.animate({'top':-_logoHeight}, _speed, _ease);
                                $loader.animate({'margin-bottom':-_loaderHeight}, _speed, _ease, function(){
                                    $splash.delay(_speed).fadeOut(_speed*2);
                                });

                            }, 3000);                       

                        });

                    });

                }); // end load

        }); // end click

}   // end function

2 个答案:

答案 0 :(得分:1)

好的,所以我从头脑中删除了这个脚本,它带有HTML5 Mobile Boilerplate ......它现在可以正常工作

<!-- This script prevents links from opening in Mobile Safari. https://gist.github.com/1042026 -->

<script>(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")</script>

答案 1 :(得分:0)

在第一个问题得到解答后,我无法加载图片。 (机器人)。我与其他一切的联系是无缝的,所以我怀疑这是一个连接问题。希望有所帮助。

相关问题