InAppBroswer完成加载后隐藏启动画面

时间:2016-02-28 11:48:53

标签: cordova phonegap-plugins phonegap-build splash-screen inappbrowser

我无法在IOS和Android上延迟启动闪屏,只在InAppBroswer完成后将其删除。这是我尝试的逻辑

config.xml中

<preference name="splashScreenDelay" value="10000" />
<preference name="AutoHideSplashScreen" value="false" />

的index.html

<html>
<head>
<title>Example App</title>
<meta charset="utf-8">
<link href="css/index.css" rel="stylesheet" type="text/css">
</head>


<script src="cordova.js" type="text/javascript" ></script>
<script src="js/main.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">

// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// Global InAppBrowser reference
var iabRef = null;


function onDeviceReady() {
iabRef = window.open('https://www.example.com/app', '_self', 'location=no,toolbar=no');

iabRef.addEventListener('loadstop', function() { 
    navigator.splashscreen.hide();
});

document.addEventListener("backbutton", function (e) {
e.preventDefault();
}, false );
}
</script>
<body>
<iframe src="https://www.example.com/app" style="width:100%; height:100%;">
</body>
</html>

闪屏显示瞬间,然后是白色屏幕约5秒钟。

索引中的逻辑是在inAppBroswer完成加载( loadstop )之后隐藏启动画面,但这似乎不起作用。

请任何想法。

的console.log(导航)

enter image description here

2 个答案:

答案 0 :(得分:0)

Inappbrowser在页面加载完成后有一个回调。

阅读documentation。见addEventListener

可能看起来像这样:

ref.addEventListener('loadstop', function() {
    navigator.splashscreen.hide();
});

答案 1 :(得分:-1)

在最新的更新中,它们似乎是与启动画面有关的错误,似乎您无法将AutoHideSplashScreen设置为false,然后使用SplashScreenDelay时间

 

但是    

似乎工作正常,因为navigator.splashscreen.hide();有效,我认为