Languages

Menu
Sites
Language
Set Initial Page For Web Application

Is there anyway to change the beginning page for a web application? I want to have a welcome page the first time and then not show it again. TIA!

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

3 Replies
Kirill Chuvilin
Here's one of the ways. Let index.hrml has such pages.
<div data-role="page" id="main-page">
    <div data-role="header" data-position="fixed">
        <h1>Main page</h1>
    </div>
    <div data-role="content">
        It is the main page
    </div>
</div>
<div data-role="page" id="hello-page">
    <div data-role="header" data-position="fixed">
        <h1>Hellow Page</h1>
    </div>
    <div data-role="content">
        It is the first launch of the app.
    </div>
</div>
Sol the initialization code.
function init() {
	document.addEventListener('tizenhwkey', function(e) { // assign hardware buttons click event handler
		if(e.keyName == 'back') { // if back button is clicked
			if (location.hash === '' || location.hash === 'main-page') { // if the main page is active
				tizen.application.getCurrentApplication().exit(); // close the application
			} else { // if not main page is active
				$.mobile.back(); // go to the previous page
			}
		}
	});
	showHelloPage(); // show the hello page for the first launch
}
$(document).bind('pageinit', init); // assign the init function call to the page initialization

function showHelloPage() {
	if (localStorage.getItem('notFirstStart') === null) { // if the first launch
		localStorage.setItem('notFirstStart', true); // the next launch will be not the first
		$.mobile.changePage('#hello-page'); // go to the hello page
	}
}
Johnny Moralez
Thanks so much! This worked like a charm. Only slight modification I had was the location.hash had a # in it, but it was great otherwise. Appreciate it!
Kirill Chuvilin
You are welcome :)