something similar to this without using javascript?
The script below is pretty basic I guess, it starts loading something "on blur".
<script>
window.onblur = function(){
TIMER = setTimeout(changeItUp, 5000);
}
window.onfocus = function(){
if(TIMER) clearTimeout(TIMER);
}
function changeItUp()
{
location.href = "http://www.yahoo.com"
}
</script>
So, if I want to redirect the user to something els开发者_如何学Ce after a certain period of inactivity, is there any chance to do this without using Javascript?
thanks.
Short answer: No
Long answer: The only way to detect user activities on a page is via Javascript. No javascript, no keyup/keydown/focus/blur events to trigger on. You could do a redirect after 5 seconds using a <meta>
tag redirect, but that's an unconditional redirect. No matter what the user is doing on the page, it'd still redirect after the specified time is elapsed.
No. HTML alone does not have the ability to redirect users as a certain time period has elapsed (conditionally). You will have to use javascript.
Meta Refresh will do something similar but only after a period of time regardless of activity...
<meta http-equiv="refresh" content="5;url=http://yahoo.com/">
Otherwise, like others stated, only JavaScript.
精彩评论