Common scripts: Reload, refresh, current, self page

Source: Internet
Author: User

Application Scenarios:

A page that needs to be refreshed periodically, and a variety of things that need to be displayed after an AJAX update.

Implementation method

How many methods can be implemented, such as:

History.go (0) window.location.reload () Window.location.reload (True) location=locationlocation.assign (location) Document.execcommand ("Refresh") window.navigate (location), Location.replace (location) document. Url=location.href

With compatibility in mind, you'll probably end up with statements

Window.location = window.location

Under the Get method access, this method is usually reloaded in the local cache, so there is a way to add a random number to the address to allow the browser to request the server address again.

The code is as follows

function reloadlocation ()    {        var t = new String (window.location);        if (T.indexof (' r= ') > 0) {            t = t.replace (/r=[0123456789\.] +/gi, ' r= ' + math.random ());        }        else {            if (t.indexof ('? ') > 0) {                t = t + ' &r= ' + math.random ()            }            else {                T = t + '? r= ' + math.random ();            }        }        window.location = t;   }

Notice of Use

This method consumes the URL R parameter, and please pay more attention to

If you have a better way, please let us know.

Common scripts: Reload, refresh, current, self page

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.