Nooby427
Nooby427

Reputation: 83

JavaScript 1 Time Interval?

window.onload = setInterval(myFunc, 5000);
function myFunc(){
    alert("This is a test.");
}

Is there any way to stop the function after 1 interval or to just have it perform 1 interval?

Upvotes: 0

Views: 54

Answers (1)

Beingnin
Beingnin

Reputation: 2422

Use setTimeout

window.onload = setTimeout(myFunc, 5000);
function myFunc(){
    alert("This is a test.");
}

Upvotes: 1

Related Questions