Javascript 当您;“将网站添加到主屏幕”;在iPhone上

Javascript 当您;“将网站添加到主屏幕”;在iPhone上,javascript,jquery,iphone,web-applications,mobile-safari,Javascript,Jquery,Iphone,Web Applications,Mobile Safari,我有一个网站,当用户点击一个按钮时,它使用ajax来引入内容。除非有人使用MobileSafari的“添加到主屏幕”功能,然后使用主屏幕上的图标打开网站,否则这一切都很正常 当有人从主屏幕图标打开网站时,它会一直工作到ajax加载部分。当有人单击链接时,屏幕会闪烁白色,然后加载内容,但是加载函数中应该运行的功能实际上都没有运行。类似于内容被加载,但是应该发生的动画没有发生,页面看起来被破坏了 这是一个奇怪的问题,我无法检查这个问题,因为我无法访问我的控制台 这是我的web应用程序的链接(尚未完成

我有一个网站,当用户点击一个按钮时,它使用ajax来引入内容。除非有人使用MobileSafari的“添加到主屏幕”功能,然后使用主屏幕上的图标打开网站,否则这一切都很正常

当有人从主屏幕图标打开网站时,它会一直工作到ajax加载部分。当有人单击链接时,屏幕会闪烁白色,然后加载内容,但是加载函数中应该运行的功能实际上都没有运行。类似于内容被加载,但是应该发生的动画没有发生,页面看起来被破坏了

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

这是我的web应用程序的链接(尚未完成)——

我的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

函数loadProject(){
变量$load=$(“#级别”);
$(文档).on('单击','内部a',函数(e){
e、 预防默认值();
$this=$(this);
var _sourceTarget='#puzzle',
_url=$this.attr('href');
$load.load(_url++_sourceTarget,function()){
动物滑鼠();
setTimeout(函数(){
$('.animal content').centerRelative();
}, 2000);
$('level selection')。动画({'left':'-200%},'u speed,'u ease,function(){
$logo.animate({'top':'10%},_speed,_ease);
$loader.animate({'margin-bottom':'10px'),_speed,_ease,function(){
setTimeout(函数(){
$logo.animate({'top':-\logoHeight},\u speed,\u ease);
$loader.animate({'margin-bottom':-\u loaderHeight},\u speed,\u ease,function(){
$splash.delay(_speed).fadeOut(_speed*2);
});
}, 3000);                       
});
});
});//端部载荷
});//结束单击
}//结束函数

好的,所以我从脑海中删除了这个脚本,它与HMLT5移动模板一起出现……现在可以正常工作了

<!-- 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>

(函数(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener(“单击”,函数(a){d=a.target;而(!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)},!window.navigator),(独立文档导航器)}中的“href”)

在回答第一个问题后,我无法加载图像。(安卓)。我与其他一切的联系似乎都没有,所以我怀疑这是否是一个联系问题。希望这会有所帮助。

为了看起来像本机应用程序,“添加到主屏幕”会隐藏地址栏。有没有可能你的JS代码引用了window.location,而当你作为本机应用程序使用它时,它就不起作用了