This can be accomplished without javascript, with this metatag:
<meta http-equiv="refresh" content="5" >
where content =”5″ are the seconds that the page will wait until refreshed.
But you said only if there was no activity, what kind for activity would that be?