Jquery mobile 使用javascript的jquery移动启动屏幕
我试图避免在启动屏幕上使用此选项,因为它不能在所有设备上工作,还有其他原因:Jquery mobile 使用javascript的jquery移动启动屏幕,jquery-mobile,splash-screen,Jquery Mobile,Splash Screen,我试图避免在启动屏幕上使用此选项,因为它不能在所有设备上工作,还有其他原因: <link rel="apple-touch-startup-image" href="img/splash.png" /> 所以我试着用它来代替,它工作得很好,直到它滑入一个新的页面,然后再像启动屏幕一样处理(例如,当计时器过期时,它变为空白-在本例中为4秒)。如何停止/限制此行为,使changePage仅包含在初始页面中 <body> <div data-role="page"
<link rel="apple-touch-startup-image" href="img/splash.png" />
所以我试着用它来代替,它工作得很好,直到它滑入一个新的页面,然后再像启动屏幕一样处理(例如,当计时器过期时,它变为空白-在本例中为4秒)。如何停止/限制此行为,使changePage仅包含在初始页面中
<body>
<div data-role="page" id="splash">
<div class="splash">
<img src="startup.jpg" alt="startup image" />
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(function() {
setTimeout(hideSplash, 4000);
});
function hideSplash() {
$.mobile.changePage("#home", "fade");
}
});//]]>
</script>
</div>
</div>
<div data-role="page" id="home">
<div data-role="header" data-backbtn="false">
<h1></h1>
</div>
<div data-role="content">
</div>
</div>
</body>
//
事实上,这只适用于苹果的移动设备
当你等待的时候,一个真正的喷溅屏幕应该只在那里给你展示一张漂亮的图片。它的目标不是让你等待真正的理由。在你的情况下,你的用户需要花费4秒的时间来让它看起来很酷
我已经修改了您的代码并将其放在下面:您将看到它现在可以工作了。要使splashscreen获得全宽/全高,请编辑css以删除边距。我已将计时器设置为2秒,我想这已经足够了。好主意,我就是这么想的。使用单页而不是多页(多数据角色=页)。对于index.html或index.php或其他内容。把你的启动页面。我稍后会解释原因 index.html
我这样做是因为假设你们有导航菜单,你们想把人们送回主页。您不必再次显示初始页面。您可以直接链接到home.html。此外,拆分页面有助于保持dom精简。我希望这能有所帮助。从品牌的角度来看,这4秒钟会很好,同时也会让你的web应用程序感觉有点土生土长。哦,顺便说一句.live()方法已被弃用。它有许多已知的问题。非常感谢您的反馈。谢谢您的反馈。非常有帮助。也适用于单个页面
<link rel="apple-touch-startup-image" href="img/splash.png" />
<head>
<!-- First include all jquery stuff -->
<script src="app.js"></script><!-- external script because we can just include it in every page -->
</head>
<body>
<div data-role="page" id="splash">
<div class="splash">
<img src="startup.jpg" alt="startup image" />
</div>
</div>
</body>
$(document).on('pageinit','#splash',function(){ // the .on() method does require jQuery 1.7 + but this will allow you to have the contained code only run when the #splash page is initialized.
setTimeout(function(){
$.mobile.changePage("home.html", "fade");
}, 4000);
});