Reputation:
This is a very basic question but how do you make a prompt appear later after the webpage has loaded? My code for the prompt looks like this:
<html>
<body>
<script type="text/javascript">
window.prompt("Prompt Here!")
</script>
</body>
</html>
What can I use to make the file execute the prompt after a little while?
Upvotes: 0
Views: 267
Reputation: 150263
document.body.onload = function(){
window.prompt("Prompt Here!");
});
Or:
<body onload="window.prompt('Prompt Here!');">
Upvotes: 0
Reputation: 2011
You'd use a setTimeout().
setTimeout(function() {
window.prompt("Prompt Here!");
}, 1000);
Upvotes: 2