hyperlink - External link in WinJS, iframe or not, doesnt matter -


i work on windows 8 app, , page use link hystory running , forward through app, have 3 or 4 links external websites(eg: facebook or site). tried run them in iframe, or make them open in default browser simple links. both method resulted in error in base.js says can't handle error (!?) searched lot before asking here. watched msdn sample works fine, if copy need in app results in same error. i use page dont have forward history, works, need on front page. ideeas? thank much.

le:

this items.js code: ( items.html page )

(function () {     "use strict";      var appviewstate = windows.ui.viewmanagement.applicationviewstate;     var ui = winjs.ui;      ui.pages.define("/pages/items/items.html", {         // function called whenever user navigates page.         // populates page elements app's data.         ready: function (element, options) {             var listview = element.queryselector(".itemslist").wincontrol;             listview.itemdatasource = data.groups.datasource;             listview.itemtemplate = element.queryselector(".itemtemplate");             listview.oniteminvoked = this._iteminvoked.bind(this);              this._initializelayout(listview, windows.ui.viewmanagement.applicationview.value);             listview.element.focus();             winjs.utilities.query("a").listen("click", this.linkclickeventhandler, false);         },          // function updates page layout in response viewstate changes.         updatelayout: function (element, viewstate, lastviewstate) {             /// <param name="element" domelement="true" />              var listview = element.queryselector(".itemslist").wincontrol;             if (lastviewstate !== viewstate) {                 if (lastviewstate === appviewstate.snapped || viewstate === appviewstate.snapped) {                     var handler = function (e) {                         listview.removeeventlistener("contentanimating", handler, false);                         e.preventdefault();                     }                     listview.addeventlistener("contentanimating", handler, false);                     var firstvisible = listview.indexoffirstvisible;                     this._initializelayout(listview, viewstate);                     if (firstvisible >= 0 && listview.itemdatasource.list.length > 0) {                         listview.indexoffirstvisible = firstvisible;                     }                 }             }         },             linkclickeventhandler: function (eventinfo) {             eventinfo.preventdefault();             var link = eventinfo.target;             winjs.navigation.navigate(link.href);         },           // function updates listview new layouts         _initializelayout: function (listview, viewstate) {             /// <param name="listview" value="winjs.ui.listview.prototype" />              if (viewstate === appviewstate.snapped) {                 listview.layout = new ui.listlayout();             } else {                 listview.layout = new ui.gridlayout();             }         },          _iteminvoked: function (args) {             var groupkey = data.groups.getat(args.detail.itemindex).key;             winjs.navigation.navigate("/pages/split/split.html", { groupkey: groupkey });         }     }); })(); 

and items.html have different types of links: of them links other application pages, can return history buttons back/forward , of them links external page. simple <a href="http://www.example.com">link</a>.these links crashes app error mentioned below. if erase next line:

 winjs.utilities.query("a").listen("click", this.linkclickeventhandler, false); 

from js script, external links works, dont have anymore history buttons in others's app pages.

you trying use navigation framework navigate external uri. it's meant used within application's local context , pages can contain 'fragments' load main nav control.

i wouldn't hook anchor tags function call, instead in linkclickeventhandler following hook internal links

winjs.utilities.query(".nav").listen("click", linkclickeventhandler, false); 

in turn internal links be

<a href="http://www.bing.com" class="nav">click me</a>

this approach hooks navigation framework internal links. approach inspect 'this.href' in handler , if contains http:// or https:// call window.open instead


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -