TIMEX
TIMEX

Reputation: 271674

In Javascript (not JQuery), how do I make the window close after 2 seconds?

How do I create a function that will close the window after 2 seconds?

<a href="" onclick="close_it(); return false;">
    Click to close the window after 2 seconds
</a>

Upvotes: 1

Views: 1321

Answers (1)

Sampson
Sampson

Reputation: 268344

You could use the setTimeout where an action is postponed for x number of milliseconds.

setTimeout(function(){
  window.close();
}, 2000);

Upvotes: 3

Related Questions