Everything on the phone returns to the previous page (wap2.0) instead of History.go (-1)

Source: Internet
Author: User

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?
    1. /* Return to Previous page */
    2. function Return_prepage ()
    3. {
    4. if (window.document.referrer== "" | | WINDOW.DOCUMENT.REFERRER==WINDOW.LOCATION.HREF)
    5. {
    6. window.location.href= "{Dede:type}[field:typelink/]{/dede:type}";
    7. }else
    8. {
    9. Window.location.href=window.document.referrer;
    10. }
    11. }

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.