Timed Page View

Control session duration. This script waits for a specified number of seconds and then triggers an action, such as a redirect or an alert message.

Wait for 5 seconds...

Counting...

Copy the Script

<script>
// Delay in milliseconds (5000 = 5 seconds)
var delay = 5000;

setTimeout(function() {
    alert("Time is up! Redirecting...");
    // window.location = "https://google.com";
}, delay);
</script>

Frequently Asked Questions

Normally no, unless you provide a 'Cancel' button that calls `clearTimeout()`. Otherwise, the action triggers automatically.

Yes. `setTimeout` keeps running in the background, though modern browsers may throttle it slightly. For long durations (e.g., 20 mins), timestamps are more accurate.

Yes. Instead of `window.location`, you can simply change the `display` style of a hidden modal div to show a popup.