html5 - How to make header menus with section labels in Windows 8 Metro using Javascript? -


How do I create a navigation menu with section labels like the header menu in the Windows 8 Metro Javascript and the picture below? ?

Enter image details here

< Div class = "post text" itemprop = "text">

Define HTML:

   & Lt; Button data-win-control = "WinJS.UI.MenuCommand" data-win-option = "{id: 'homeMenuItem', label: 'home'}" & gt; & Lt; / Button & gt; & Lt; / Div & gt; & Lt ;! - Content that will be loaded and displayed. - & gt; & Lt; Header aria-label = "header content" roll = "banner" & gt; & Lt; Button class = "win-backbutton" aria-label = "back" & gt; & Lt; / Button & gt; & Lt; Div class = "titillaria win-type-alpesis" & gt; & Lt; Button class = "titlecontainer" & gt; & Lt; H1 & gt; & Lt; Span class = "pagetitle" & gt; Header & lt; / Span & gt; & Lt; Span class = "chevron win-type-x-big" & gt; & Amp; # Xe099 & lt; / Span & gt; & Lt; / H1> & Lt; / Button & gt; & Lt; H2 class = "pagesubtitle" & gt; With clean Finnish effects & lt; / H2 & gt; & Lt; / Div & gt; & Lt; / Header & gt;   

Then comes javascript:

  // whenever a user navigates on this page, this function is called. It browses page elements with data of the // app: Tasks (Elements, Options) {document.querySelector ("HeaderKey"). AddEventListener ("click", this.showHeaderMenu, incorrect); Document.getElementById ("Section 1"). AddEventListener ("click", function () {self.goToSection (0);}, false); Document.getElementById ("section2"). AddEventListener ("click", function () {self.goToSection (1);}, false); Document.getElementById ("section3"). AddEventListener ("click", function () {self.goToSection (2);}, false); Document.getElementById ("homeMenuItem"). AddEventListener ("click", function () {self.goHome ();}, false); }, // connects the menu to an anchor and shows it the header menu: function () {var title = document.query selector ("header header"); Var menu = document.getElementById ("headerMenu"). WinControl; Menu.anchor = Title; Menu.placement = "bottom"; Menu.alignment = "left"; Menu.show (); }, // Go to a section goToSection: function (section) {switch (section) {Case 1: WinJS.Navigation.navigate ("/ pages / section1 / section1.html"); break; Case 2: Vinj S. Navigation. Navigate ("/ page / section 2 / section 2"); break; Case 3: WinJS.Navigation.navigate ("/ pages / section3 / section3.html"); break; } WinJS.log & amp; WinJS.log ("You are viewing the #" + section + "section.", "Sample", "Status"); }, // Go to home screen goHome: function () {WinJS.Navigation.navigate ("/ default.html"); },   

Just wanted to share, hope it helps someone!

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -