Recently in doing wap2.0 Mobile WAP, write back to the previous page, the beginning is to use History.go (-1);
found that only some of the machines on the phone can be like Windows Mobile and on other machines such as Nokia and ophone phones
On these are not very good, after wrestling finally think of a cottage method to solve this rogue problem ...
Not directly with the return function of the phone, but by reading the referrer on the previous page link to achieve the phone back to the previous function
The code is as follows:
Javascript CODE
[JavaScript]View Plaincopyprint?
- /* Return to Previous page */
- function Return_prepage ()
- {
- if (window.document.referrer== "" | | WINDOW.DOCUMENT.REFERRER==WINDOW.LOCATION.HREF)
- {
- window.location.href= "{Dede:type}[field:typelink/]{/dede:type}";
- }else
- {
- Window.location.href=window.document.referrer;
- }
- }
Call directly where it is needed;
Javascript:return_prepage ();
Monitor browser to return to previous page
$ (document). Ready (function ($) { if (window.history & & window.history.pushstate) { $ (window). On (' Popstate ', function () { var hashLocation = location.hash; var hashsplit = hashlocation.split ("#!/"); var hashname = hashsplit[1]; if (hashname !== ') { var hash = window.location.hash; if (hash === ") { alert (' Back-button click '); } } }); window.history.pushstate (' Forward ', null, './#forward '); } });
Everything on the phone returns to the previous page (wap2.0) instead of History.go (-1)