Call page from another page
-
@Ahmed-Elshorbagy Perhaps you are looking for
position
attribute.
-
I modified the position,thank you But I sell cannot call page2.html from page1.html, I don’t want to put the who;e application in one page
-
@Ahmed-Elshorbagy You wouldn’t use an iframe to call additional pages. The example here:
http://tutorial.onsen.io/?framework=vanilla&category=Reference&module=navigator
Shows navigation and the templates are in one page. If you do not want that, just create individual files and do not use the template tag. A good example of that is in this eBook template example I made for people.
https://github.com/munsterlander/Onsen-Examples/tree/master/eBook-Template
-
I downloaded the example but it did not work, it displayed an empty page.
-
@Ahmed-Elshorbagy The tutorial?
-
Yes
-
@Ahmed-Elshorbagy Copy all of this to the index.html page and give it a try:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="mobile-web-app-capable" content="yes" /> <meta http-equiv="Content-Security-Policy" content="default-src * data:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'"> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link href='https://fonts.googleapis.com/css?family=Roboto:400,300italic,300,400italic,500,700,700italic,500italic' rel='stylesheet' type='text/css'> <title>Onsen UI Forum Help by Munsterlander</title> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css" type="text/css" media="all" /> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.css"> <script src="https://unpkg.com/onsenui"></script> <script> document.addEventListener('init', function(event) { var page = event.target; if (page.id === 'page1') { page.querySelector('#push-button').onclick = function() { document.querySelector('#myNavigator').pushPage('page2.html', {data: {title: 'Page 2'}}); }; } else if (page.id === 'page2') { page.querySelector('ons-toolbar .center').innerHTML = page.data.title; } }); </script> </head> <body> <ons-navigator id="myNavigator" page="page1.html"></ons-navigator> <ons-template id="page1.html"> <ons-page id="page1"> <ons-toolbar> <div class="center">Page 1</div> </ons-toolbar> <p>This is the first page.</p> <ons-button id="push-button">Push page</ons-button> </ons-page> </ons-template> <ons-template id="page2.html"> <ons-page id="page2"> <ons-toolbar> <div class="left"><ons-back-button>Back</ons-back-button></div> <div class="center"></div> </ons-toolbar> <p>This is the second page.</p> </ons-page> </ons-template> </body> </html>
-
it is working now
-
@Ahmed-Elshorbagy Glad it worked! Upvote arrows for the solution are on the bottom right of each post. Thanks!
-
@munsterlander But it does not make sense since you were trying to load the html page from different files. The update you made was still put two templates in a same file?