app.js http://code.kik.com/app/2/index.html
(function(App,$){ var appLoad = App.load; var appBack = App.back; App.load = function(pageInfo, args, options, callback){ var pageName = null; var url = null; if(typeof pageInfo ==="string"){ pageName = pageInfo; }else if(typeof pageInfo === "object"){ pageName = pageInfo.name; url = pageInfo.url; } pushState(pageName); // // 是否有同名的页面已经加载 if (App._Pages.has(pageName)) { appLoad(pageName, args, options, callback); return; } // 解析传入的html function parsePage(html){ return html; // TODO we can enhance this } $.get(url,function(res){ var pageHtml = parsePage(res); var page = $(pageHtml).appendTo("body"); App.add(pageName,page[0]); appLoad(pageName, args, options, callback); }); }; var internalBack = false; App.back = function(pageName, callback){ internalBack = true; appBack(pageName, callback); history.back(); }; function pushState(pageName){ window.history.pushState({name:pageName},"","#/"+pageName); } window.onpopstate = function(event){ var state = event.state; if(!internalBack){ appBack(); } internalBack = false; } })(window.App,$);
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。