Safari non-trace browsing impact localstorage

Source: Internet
Author: User
Tags sessionstorage

Recently encountered a problem in the project, there is a login page, click Login, the company two local tyrants gold can not jump normally (but the login request has been sent to the server), other people's phones are normal. The project is also anxious to go online, the heart of this crazy ah. Finally calm down, finally to solve the problem.

Resolution process:

Because the server has received the client's AJAX request, so it depends on whether the client received a response from the server, under the callback Success function alert (Data.code), found that the response is received, and data.code=0, to meet the jump condition, So continue alert in success else, and eventually position the problem to Sessionstorage.setitem (' Loginphone ', loginphone); above, Sessionstorage is H5 's character, Mobile-phone browsers are generally supported, with alert (Sessionstorage), (Sessionstorage.setitem), and alert (typeof (Sessionstorage.setitem)) found to be normal, typeof (Sessionstorage.setitem) is a function, since the existence of sessionstorage, and why can not be normal execution. Finally, through degrees Niang found the root cause of the problem---safari non-trace browsing will affect localstorage. So you just have to change this sentence a little bit.

try {                Sessionstorage.setitem ("Loginphone", Loginphone),            } catch (e) {               alert ("You are in a no-trace view, unable to jump for You");            }

Here is the code before the modification:

 var Loginphone; function Submitbindinfo () {if (Checksubmitmobile ($ ("#phone-wrap")) && Checkcode () &&checkcontract (            ) {var param={phone:loginphone, authcode:$ ("#verifycode"). Val ()            };                $.ajax ({type: "POST", url: "/portal/member/login.do", Data:param,                     DataType: "JSON", timeout:20000, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {                                           if (xmlhttprequest.status==408) {alert ("The system is busy, please try later");                    }else{Alert (xmlhttprequest.status+ "error");                }}, Success:function (data) {dosuccess (data);        }            });        }} function dosuccess (data) {if (data.code!=0) {loginfailcallback (DATA.DESC);   }else{         Sessionstorage.setitem (' Loginphone ', loginphone);        DOREDIRCT (); }} function doredirct () {switch (hash) {case "#member": window.location.href= "/po                Rtal/member/showmember.do ";            Break                Case "#myOrder": window.location.href= "/portal/myorder/showorder.do";            Break                Case "#myCoupon": window.location.href= "/portal/mycoupon/showcoupon.do";            Break                Default:window.location.href= "/portal/sinopec/step0.do";        Break }    }

  

Safari non-trace browsing impact localstorage

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.