History.back ();
This code has a natural flaw, used to know, in the application of H5, especially the imitation of mobile phone applications, this is not enough.
Close-up a section of JS to achieve similar functions, such as repeated and do not like 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); In history there is no incoming URL now, in Add back} historyarray.push (URL); Historyutils.savelocal (Historyarray); }, Back:function () {var historyarray = historyutils.getlocal (); var currentpage = Historyarray.pop ();//Remove current page, pop take last, similar to 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 ();
H5 application return button JS code design, design ideas imitate stack