Show and hide the application's splash screen.
method
access function
From version 3.0, Cordova implements device -level APIs as plugins . Using the CLI commands , described in Command Line Interface , it is possible to add or delete a project, for this function:plugin
$ cordova plugin add org.apache.cordova.splashscreen
$ cordova plugin ls
[ 'org.apache.cordova.splashscreen' ]
$ cordova plugin rm org.apache.cordova.splashscreen
These commands apply to all targeted platforms, but modify platform-specific configuration settings as described below:
-
(on android
app/res/xml/config.xml
)<feature name="SplashScreen"> <param name="android-package" value="org.apache.cordova.SplashScreen" /> </feature>
-
(on iOS
config.xml
)<feature name="SplashScreen"> <param name="ios-package" value="CDVSplashScreen" /> </feature>
Some platforms may support this feature without any special configuration. See Platform Support in the Overview section .
See Graphics and Splash Screens for information on how to configure these images .
splashscreen.show
Display the initial screen.
navigator.splashscreen.show();
illustrate
This method displays the application's splash screen.
Supported Platforms
- Android system
- iOS
- Windows Phone 7 and 8
- Windows 8
quick example
navigator.splashscreen.show();
complete example
<!DOCTYPE html>
<html>
<head>
<title>Splashscreen Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
navigator.splashscreen.show();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
splashscreen.hide
The splash screen for dismissal.
navigator.splashscreen.hide();
illustrate
This method closes the application's splash screen.
Supported Platforms
- Android system
- blackberry 10
- iOS
- Windows Phone 7 and 8
- Windows 8
quick example
navigator.splashscreen.hide();
complete example
<!DOCTYPE html>
<html>
<head>
<title>Splashscreen Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
navigator.splashscreen.hide();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
iOS quirks
config.xml
The file 's AutoHideSplashScreen
setting must be false
. To delay the hidden splash screen for two seconds , add the following in the timer deviceready
event handler:
setTimeout(function() {
navigator.splashscreen.hide();
}, 2000);