Luke
Luke

Reputation: 35

How to delay onload script for overlay

I am currently using this code to trigger an overlay:

<body onload="toggleOverlay();">

How do I delay this for a set time in milliseconds or seconds?

Upvotes: 1

Views: 1794

Answers (1)

DotMG
DotMG

Reputation: 36

You can delay the execution of toggleOverlay() using setTimeout().

onload="setTimeout('toggleOverlay()', 1000);

When the page loads, the setTimeout is executed but not yet the toggleOverlay.

Upvotes: 1

Related Questions