简体   繁体   中英

ASP.NET MVC Forcing Page Redirect After 5 Minutes (Different Pages)

I am building a gallery website that allows visitors to view different photographs. I want to require visitors to register once they spend more than 5 minutes on the website. This includes page redirections . So, I am trying to come up with a way to redirect visitors to my registration page and disallow any further photography viewing until they make an account.

JS code like the following only keeps track of the currently active page:

var delay = 1000; 
setTimeout(function(){ window.location = URL; }, delay);

Is there any way to keep track of the visitor's overall time-spent? And force a page redirection if the time exceeds 5 minutes?

Any guidance will be highly appreciated. Thanks.

window.setTimeout(window.location.href = "https://www.google.co.in",300000 );

在页面加载或窗口加载中使用以上代码。(5min = 300000ms)

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