JS: Browser Functions
Browser Functions JavaScript Functions
Please note most functions apply to both Kiosk Browser and Launcher but some are specific the individual product.
You can find the JavaScript test page at https://www.android-kiosk.com/jstest.htm Just set this as the Kiosk URL on your device to test the functions.
Check if Kiosk Browser is in focus, requires version 2.0.22 or higher.
Check if Kiosk Browser is in focus, requires version 2.0.38 or higher.
Sets Kiosk Browser as the default launcher (Samsung Knox and/or provisioned devices only), requires version 2.6.6 or higher.
Go back or forward, requires version 2.0.34 or higher.
Show or hide bookmarks bar, requires version 2.0.38 or higher.
Get Kiosk Title string, requires version 2.0.34 or higher.
Set Kiosk Title string, requires version 2.0.34 or higher.
Clear session data (cache, cookies, forms & web storage), requires version 2.5.4 or higher.
Put String value in KB Storage, requires version 2.5.8 or higher.
Get String value from KB Storage, requires version 2.5.8 or higher.
Clear all String values in KB Storage, requires version 2.5.8 or higher.
Delays idle timeout by default idle timeout, requires version 2.6.2 or higher.
Specify a key event listener to handle key events yourself, requires version 2.6.2 or higher. Please note the listener is reset whenever a new page is loaded. Key event codes can be found here.
Enables/Disables the pausing of JavaScript timers when the device goes to sleep / loses focus. This setting can also be controlled via Settings > Advanced (default is enabled). Requires version 2.6.6 or higher.
Please note most functions apply to both Kiosk Browser and Launcher but some are specific the individual product.
You can find the JavaScript test page at https://www.android-kiosk.com/jstest.htm Just set this as the Kiosk URL on your device to test the functions.
Is App In Focus?
Check if Kiosk Browser is in focus, requires version 2.0.22 or higher.
<script>
//IS KIOSK BROWSER IN FOCUS?
function isAppInFocus() {
return Android.isAppInFocus();
}
</script>
<a href="javascript:console.log(isAppInFocus());">Is Kiosk Browser in Focus?</a>
Regain Focus
Check if Kiosk Browser is in focus, requires version 2.0.38 or higher.
<script>
//REGAIN FOCUS
function regainFocus() {
return Android.regainFocus();
}
</script>
<a href="javascript:regainFocus();">Regain Focus, brings Kiosk Browser back into focus</a>
Set Default Launcher
Sets Kiosk Browser as the default launcher (Samsung Knox and/or provisioned devices only), requires version 2.6.6 or higher.
<script>
function setDefaultLauncher() {
return Android.setDefaultLauncher();
}
</script>
<a href="setDefaultLauncher();">Sets Kiosk Browser as the default launcher</a>
Go Back/Forward
Go back or forward, requires version 2.0.34 or higher.
<script>
//GO BACK
function back() {
Android.back();
}
//GO FORWARD
function forward() {
Android.forward();
}
</script>
<a href="javascript:back();">Go Back</a>
<a href="javascript:forward();">Go Forward</a>
Show/Hide Bookmarks Bar
Show or hide bookmarks bar, requires version 2.0.38 or higher.
<script>
//SHOW BOOKMARKS BAR
function showBookmarks() {
Android.showBookmarks();
}
//HIDE BOOKMARKS BAR
function hideBookmarks() {
Android.hideBookmarks();
}
</script>
<a href="javascript:showBookmarks();">Show Bookmarks Bar</a>
<a href="javascript:hideBookmarks();">Hide Bookmarks Bar</a>
Get Kiosk Title
Get Kiosk Title string, requires version 2.0.34 or higher.
<script>
//GET KIOSK TITLE
function getKioskTitle() {
return Android.getKioskTitle();
}
</script>
<a href="javascript:console.log(getKioskTitle());">Get Kiosk Title</a>
Get Kiosk Title
Set Kiosk Title string, requires version 2.0.34 or higher.
<script>
//SET KIOSK TITLE
function setKioskTitle(title) {
Android.setKioskTitle(title);
}
</script>
<a href="javascript:setKioskTitle('Kiosk App');">Set Kiosk Title</a>
Clear Session
Clear session data (cache, cookies, forms & web storage), requires version 2.5.4 or higher.
<script>
function clearSession(clearCache,clearCookies,clearForms,clearWebStorage) {
Android.clearSession(clearCache,clearCookies,clearForms,clearWebStorage);
}
</script>
<a href="javascript:clearSession(true,true,true,true);">Clear Session</a>
Put String Value
Put String value in KB Storage, requires version 2.5.8 or higher.
<script>
//PUT STRING VALUE
function putStringValue(key,value) {
Android.putStringValue(key,value);
}
</script>
<a href="javascript:putStringValue('unique','mystring');">Put String value in KB Storage</a>
Get String Value
Get String value from KB Storage, requires version 2.5.8 or higher.
<script>
//GET STRING VALUE
function getStringValue(key) {
return Android.getStringValue(key);
}
</script>
<a href="javascript:showAndroidToast(getStringValue('unique'));">Get String value from KB Storage</a>
Clear all String Values
Clear all String values in KB Storage, requires version 2.5.8 or higher.
<script>
//CLEAR ALL STRING VALUES
function clearStringValues() {
return Android.clearStringValues();
}
</script>
<a href="javascript:clearStringValues();">Clear all String values in KB Storage</a>
Delay Idle Timeout
Delays idle timeout by default idle timeout, requires version 2.6.2 or higher.
<script>
//DELAY IDLE TIMEOUT
function delayIdleTimeout() {
return Android.delayIdleTimeout();
}
</script>
<a href="javascript:delayIdleTimeout();">Delays idle timeout by default idle timeout</a>
Key Event Listener
Specify a key event listener to handle key events yourself, requires version 2.6.2 or higher. Please note the listener is reset whenever a new page is loaded. Key event codes can be found here.
<script>
//MY CUSTOM LISTENER
function myKeyEventListener(keyCode, displayLabel, number) {
console.log("keyCode: " + keyCode);
console.log("displayLabel: " + displayLabel);
console.log("number: " +number);
}
//REGISTER LISTENER
Android.registerKeyEventListener("myKeyEventListener");
//DE-REGISTER LISTENER
registerKeyEventListener(null);
</script>
Pause JavaScript Timers On Sleep
Enables/Disables the pausing of JavaScript timers when the device goes to sleep / loses focus. This setting can also be controlled via Settings > Advanced (default is enabled). Requires version 2.6.6 or higher.
<script>
function pauseJavaScriptTimersOnSleep(pause) {
return Android.pauseJavaScriptTimersOnSleep(pause);
}
</script>
<a href="pauseJavaScriptTimersOnSleep(true);">Pause JavaScript Timers On Sleep</a>
Updated on: 03/03/2021
Thank you!