A slightly unusual problem. I need to limit the speed that an html page downloads at, and I need the code that achieves this to fit within the < head > section. Is this possible?
Tried PHP's sleep function but it seems to have no effect.
A slightly unusual problem. I need to limit the speed that an html page downloads at, and I need the code that achieves this to fit within the < head > section. Is this possible?
Tried PHP's sleep function but it seems to have no effect.
You could use setTimeout()
as described on W3Schools.
First, you would change the display
property of the body to none
.
<body style="display:none">
Then you would create a function that gets the body
element and changes the display
property to block
.
function myFunction() {
var body = document.getElementsByTagName("body")[0];
body.style.display = "block";
}
Followed by the use of setTimeout()
. In the example below, I have set the timeout to 3 seconds. The function will execute after 3 seconds.
setTimeout(myFunction, 3000);
function myFunction() {
var body = document.getElementsByTagName("body")[0];
body.style.display = "block";
}
setTimeout(myFunction, 3000);
<html>
<head>
</head>
<body style="display:none">
<h1>Time out</h1>
</body>
</html>