History.back ();
The code has a natural flaw, used to know, in H5 applications, especially when imitating mobile applications, which is not enough.
In the magnification period JS in order to achieve similar characteristics, please light spray.
Not much to say, on the code:
/** * Created by [email protected] on 2015/5/28. */var historyutils = {add:function (URL) {var historyarray = historyutils.getlocal (); if (!historyarray) {historyarray = []; } var currentpage = Historyarray.pop (); if (currentpage && currentpage = = URL) {//do nothing} else if (currentpage) {Histor Yarray.push (currentpage); There are no URLs in history that are now passed in. On add back} historyarray.push (URL); Historyutils.savelocal (Historyarray); }, Back:function () {var historyarray = historyutils.getlocal (); var currentpage = Historyarray.pop ();//Remove the current page, pop take the last, similar stack var history = Historyarray.pop (); if (!history) {//No history page Historyutils.add (currentpage);//Add the current page back to the array return; } historyutils.savelocal (Historyarray); Window.location.href = history; }, Getlocal:function () {var result = Window.sessionStorage.getItem (hiStoryutils.key); if (!result) {return null; } return Json.parse (result); }, Savelocal:function (data) {Window.sessionStorage.setItem (Historyutils.key, json.stringify (data)); }, Init:function () {historyutils.savelocal ([]); }, Key: "_history_"}historyutils.add (window.location.href);
Call where you need to implement back
Historyutils.back ();
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
The H5 application returns the JS code design of the button and designs The imitation stack