Search code examples
cordovaonsen-ui

How to jump from one html file to another in Onsen UI (both html files' content begin with <html>)


I have two html files, both file's content begin with tag html, not begin with tag ons-page or ons-navigator.

One is index.html, in this file I have some ons-page(such as user login, signup, forget password), The other is main.html, the main business logic UI/logic.

The question is: When user login process finished, How can I jump from index.html to main.html? And How can I pass some data from index.html to main.html.

window.open("main.html", '_self'); 

The code above works on PC browser only, not Android.

window.url = "main.html"; 

The code above not works on both PC browser and Android.


Solution

  • You cannot use Onsen UI navigation patterns if your file doesn't contain ons-template or if the content is not spread in different HTML files. Is there any issue in using ons-template or dividing the content in multiple files? Moreover, which element are you using to perform the page navigation? If you are using ons-navigator with var='myNavigator', you can execute a function which contains the following instruction:

    myNavigator.pushPage('main.html', {param1: 'bla'})