I want to make a script that will refresh the page when someone clicks anywhere on the page, except for hyperlinks (which, we know what they do) but ONLY for IE7

document.onclick=function(){
var browserName=navigator.appName;
var browserVer=parseInt(navigator.appVersion);
if (browserName=="Microsoft Internet Explorer" && browserVer==7)
history.go(0);
}

this doesnt work. My lack of understanding of js is probably to blame here. I think the problem with this script is that this function is not loaded on startup of the page? Total noob here. I dunno, any ideas?