...

View Full Version : Code that automatically redirects a visitor after they click anywhere on the page?



tridentspk
09-05-2011, 11:55 PM
I'm looking for code which does the following:

When a visitor visits my website and clicks anywhere on the page, (regardless of where the mouse clicks) it will automatically redirect him to another site.

I think an event listener might be a solution, but I'm not sure.

Thanks a lot for any help on this :)

If possible, I would like there to be a 2 second time delay before it does the redirection.

Philip M
09-06-2011, 12:12 PM
<body onclick = "redirect()">
CLICK ANYWHERE ON THE PAGE TO REDIRECT AFTER 2 SECONDS

<script type = "text/javascript">
function redirect() {
setTimeout('window.location = "http://www.google.com"', 2000);
}

</script>


"More than any other time in history, mankind faces a crossroads. One path leads to despair and utter hopelessness. The other, to total extinction. Let us pray we have the wisdom to choose correctly."
Woody Allen - US movie actor, comedian, & director (1935 - )



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum