There is a link that opens a random image from unsplash. Here it is: https://source.unsplash.com/random/1920x1080
I intend to open ten tabs with random images. Here is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-7">
<style>
body{margin:0px;color:#252430;background-color:#fff}
p{margin-top: 10em; font-size: 2em;}
</style>
<script>
function openitall(){
var i;
for(i=1;i<=10;i++){
window.open("https://source.unsplash.com/random/1920x1080","_blank");
}
}
</script>
</head>
<body onload="openitall()">
<p align=center>I am a page opening ten random images in new tabs.</p>
</body>
</html>
But that way I get ten same images. So I am thinking of a delay:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-7">
<style>
body{margin:0px;color:#252430;background-color:#fff}
p{margin-top: 10em; font-size: 2em;}
</style>
<script>
function openitall(){
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),3000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080","_blank"),6000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),3000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),6000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),9000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),12000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),15000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),18000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),21000);
setTimeout(window.open("https://source.unsplash.com/random/1920x1080", "_blank"),24000);
}
</script>
</head>
<body onload="openitall()">
<p align=center>I am a page opening ten random images in new tabs.</p>
</body>
</html>
But that doesn't help either. All the tabs are immediately opened without any delay. Could you please help?
EDIT: posting this:
Here it is without the parenthesis:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-7">
<style>
body{margin:0px;color:#252430;background-color:#fff}
p{margin-top: 10em; font-size: 2em;}
</style>
<script>
function myOpen(){
window.open("https://source.unsplash.com/random/1920x1080", "_blank");
}
function openitall(){
for(var i=1;i<=10;i++){
setTimeout(myOpen,5000);
}
}
</script>
</head>
<body onload="openitall()">
<p align=center>I am a page opening ten random images in new tabs.</p>
</body>
</html>
And it still does not work..