简体   繁体   中英

Reload the page when I switch to another tab and come back

I have used the below Javascript code.

$(window).focus(function () {
    window.location.reload(true);
});

Which was called in focus event. But whenever I switch or click on some other application or desktop tab, it's started reloading. I need it to be reloaded only when I switch over tabs not when I clicked somewhere other than a browser.

See Arthik, If my understanding is correct - you need to take OR give some ID for the TAB control and modify your code as :

$(#tabID).focus(function () {
    window.location.reload(true);
});

tabID - is the ID of you Tab control ( or the DIV -as you are using )

if mistaken - pls Update your query for our better understanding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM