2013-08-20 80 views
0

我有一个网站,当用户单击按钮时使用ajax引入内容。除非有人使用移动Safari的“添加到主屏幕”功能,然后使用主屏幕上的图标打开网站,否则这种方式可以正常工作。当您在iPhone上“添加网站到主屏幕”时,Ajax会中断

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

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

这里是我的web应用程序的链接(它尚未完成) - 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 

回答

1

好了,所以我从我的头上取下这个脚本,它带着HMLT5 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> 
+0

为了看起来像原生应用程序,“添加到主屏幕”隐藏地址栏。是否有可能您的JS代码是指window.location,并且当您将其作为本地应用程序执行时不起作用 – Chandra

0

我在第一个问题得到解答后加载图像时遇到了问题。 (机器人)。我与其他任何事物的联系都是无形的,所以我怀疑它是一个连接问题。希望有所帮助。

相关问题