簡體   English   中英

iPad上的移動網站啟動屏幕

[英]Start up screen for mobile website on iPad

我將以下腳本添加到我的移動網站的啟動屏幕中(將其添加到主屏幕后)。

<script>
(function(){

    var a;
    if(navigator.platform === "iPad") {
        a = window.orientation!==90||window.orientation === -90 ? 
             "/assets/img/startup/startup-tablet-landscape.png" :
             "/assets/img/startup/startup-tablet-portrait.png";
    }
    else {
        a = window.devicePixelRatio === 2 ? 
             "/assets/img/startup/startup-retina.png" :
             "/assets/img/startup/startup.png";
    }
    document.write('<link rel="apple-touch-startup-image" href="' + a + '"/>');

})();
</script>

這適用於iPhone,但不適用於iPad,我正在新iPad上進行測試,這有關系嗎? 在加載之前,我得到的只是一個白色屏幕

您不需要javascript,可以使用此代碼段,它應自動選擇合適的圖像:

<!-- For iPhone 4 with high-resolution Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png">

<!-- For first-generation iPad: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png">

<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png">


<!-- 320x460 for iPhone 3GS -->
<link rel="apple-touch-startup-image" media="(max-device-width: 480px) and not (-webkit-min-device-pixel-ratio: 2)" href="startup-iphone.png">

<!-- 640x920 for retina display -->
<link rel="apple-touch-startup-image" media="(max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)" href="startup-iphone4.png">

<!-- iPad Portrait 768x1004 -->
<link rel="apple-touch-startup-image" media="(min-device-width: 768px) and (orientation: portrait)" href="startup-iPad-portrait.png">

<!-- iPad Landscape 1024x748 -->
<link rel="apple-touch-startup-image" media="(min-device-width: 768px) and (orientation: landscape)" href="startup-iPad-landscape.png"> 

資料來源: https : //gist.github.com/1375646

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM