javascript - jquery mobile history.back() only work for first time -
currently have encountered problem history. ().
i have 2 pages, pagea.html, pageb.html.
i'm using next code go next page , previous page
// go next page function changepage(url) { $.mobile.pagecontainer.pagecontainer("change", url, { allowsamepagetransition: true, transition: 'none', showloadmsg: false, reloadpage: false, changehash: true }) } //back previous page function backtopreviouspage(){ alert("back"); history.back(); } the codes work fine first time, flow below
first time : pagea > pageb (click on button once) > pagea
so have pagea again. , here's problem comes.
second time : pagea > pageb (first click button no respond, click sec time) > pagea
when comes 3rd time, need click on button 3 times can create history.back() work, can alert message, backtoprevious function called.
so problem below:
1st navigate : pagea > pageb > pagea (1 click) 2nd navigate : pagea > pageb > pagea (2 clicks) 3rd naviagate : pagea > pageb > pagea (3 clicks)and on....
ii can't hardcode navigate pagea in backtoprevious function, because not can navigate pageb pagea, can navigate pageb other page.
so far have tried this
history.back(-1); and this
<a data-rel="back" href="javascript:history.back(1)" data-theme="a">back</a> but still can't prepare problem.
appreciate if can tell me doing wrong. give thanks you.
just utilize code.
function changepage() { $.mobile.changepage("pagea.html"); homecoming false; } function backtopreviouspage(){ navigator.app.backhistory(); } javascript jquery jquery-mobile cordova
No comments:
Post a Comment