The browser Javascript cannot use window. location. reload () to refresh the page, location. reload
The scenario is like this. The page has an ajax request during initialization. There is a button on the page and the window is executed when clicked. location. reload (). Normally, after reload (), the page still sends a request to the background. However, in the android browser, after reoad, the request is always the data requested when the page is opened for the first time. It can be understood that the request is cached, but it is not tested or determined whether the request is cached.
Solution:Use window. location. href = "window. location. href + random number" to replace window. location. reload (). Remember to add a random number, otherwise it will not work. Of course, you can also use a tag a and then set href = "window. location. href + random number ".
Further, you can set this parameter only for the browser, so you have to determine whether the browser is used. You can use window. navigator. userAgent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13F69 MicroMessenger/6.3.16. Determine whether the browser is built based on the keyword MicroMessenger. The judgment function is as follows:
Function isWeiXin () {var ua = window. navigator. userAgent. toLowerCase (); if (ua. match (/MicroMessenger/I) = 'micromessenger ') {return true;} else {return false ;}}
The above is all about the content of this article. For more information about the JavaScript syntax, see: JavaScript reference tutorial and JavaScript code style guide. I also hope you can provide more support.