Reputation: 1814
I am really new to Windows 8 App Development.I am creating a Windows 8 App in which I need to click a button and open another page. I am developing this windows app using HTML/CSS and Javascript. How can I navigate to another page using a button click? I have tried several with window.ways which I can use with HTML/Javascript for Browser web pages. But non of them are working. Is there a special way to do this in Windows 8 App development? Can anybody please explain with an example.
Thank you.
Upvotes: 1
Views: 494
Reputation: 166
I could guess that maybe your problem is in understanding the different contexts? A page can run in the "local context" which gives it the permissions of your app and access to the Windows 8 API. A page can instead be run in the "web context" in this context it does not have access to the Windows 8 API but can execute remote code.
Basically, you start in the local context...code that is part of your app. From there, you can link to pages in your app's package (these would run in the local context). You could also link to things outside of your app package (these things would run in the web context). The confusing thing is when you link to something in the web context. Basically, since replacing the current page/screen with the web-context would make you lose all access to the Windows 8 API, when you link to something in the web context, Windows 8 won't replace the screen with that page, instead it will open up IE10 and load the page in there; That way you don't lose control of your app. The trick to loading stuff in the web context is to load it in an iframe which is in the web context. But you always need to keep the main page itself in the local/app context.
For your reference: Urls starting in "ms-appx:///" load in the local context. Urls starting in "ms-appx-web:///", "http://" or "https://" load in the web context. As far as I remember, if unspecified, links are in the same context as the page they are in.
In terms of how to do it...you should be able to use <a href="..."> as well as the usual javascript ways. It's been a while since I've coded for Windows 8, but I don't remember that part being different from how I did things in normal web development.
Unless of course you are talking about the PageControl object or the navigation template. So many things. Either way, I strongly recommended getting the free book "Programming Windows 8 Apps with HTML, CSS and Javascript" by Kraig Brockschmidt. It's an easy read full of examples and I'm sure that will solve 99% of your questions if you are new to this.
Upvotes: 1
Reputation: 143
So you tried the
href="____.html"
try dropping the ".html" so it is just
href="____"
And do you have the controller to handle it when you tell it to go the page?
Upvotes: 0