I have a website (built in Wordpress) that needs to close after a visitor has been there for 5 minutes. (The people visiting are taking a survey that links out to this page and I need to get them back to the survey after browsing the outside website for five minutes). Displaying a countdown timer in a top corner would be great but not necessary.
I figured out how to get Javascript to close a page on a timer BUT I want the visitors to be able to browse multiple pages without a) me having to place the timer on every page and b) the timer resetting.
This is the webpage: http://www.cancerclinicalstudyguide.com
Thanks
There are a few ways to solve this.
You could also not use a timer. I don't really get why you want to restrict the time the users have.
If i am right, you have a survey, redirect user to 3rd party website and bring back to original site after some timer. The short answer can't be done directly as it would involve adding some scripts to third party side.
You can use iframe for the same. The dom structure would be somewhere along the lines of
.container
iframe
.timer
form
Now comes the tricky part, set iframe
display to none. Create two functions showFrame
and hideFrame
. The name says most of it all, but remember to toggle visibility of form also as you don't want that to be displayed on other page. Also added a timer just in case you want a clock.
When you reach this point call function showFrame
remember to set src
attribute for iframe. and call setTimeout
function with hideFrame
function and the time you want user back to your site.
Here is some basic css that might help you along the way
iframe {
position: fixed;
width: 100%;
height: 100%;
}
.timer {
position: fixed;
right: 40px;
top: 40px;
}