Here is a late reply because the accepted answer does not explain what the problem was in your code and adds jQuery when the solution is not necessarily this.
There are some problems with your code:
The first is that CSS and Javascript need HTML tags for the browser to be able to interpret this code as what it is and not HTML. I mean, instead of this piece:
body{overflow-x:hidden;overflow-y:hidden;}
<div id="bloquear" style="position:absolute;top:0;left:0;width:100%;height:100%; background:#333;"></div>
function liberar(){
document.getElementById('bloquear').style.display='none';
document.body.style.overflow='scroll';
}
<body onload="liberar">
should look like this: (with javascript inside tags <script>
)
<style>
body{overflow-x:hidden;overflow-y:hidden;}
</style>
<div id="bloquear" style="position:absolute;top:0;left:0;width:100%;height:100%; background:#333;"></div>
<script>
function liberar(){
document.getElementById('bloquear').style.display='none';
document.body.style.overflow='scroll';
}
</script>
<body onload="liberar">
Another problem is that the declaration of the beginning of the body
ocerre after HTML has already appeared on the page. This is invalid. Tag <body>
tells the browser that there gets the page body and there can be HTML outside the body. So this line:
<div id="bloquear" style="position:absolute;top:0;left:0;width:100%;height:100%; background:#333;"></div>
should be inserted after the tag <body onload="liberar">
Another problem is that the release function will not be racing if it does not add ()
at the end. That is to say <body onload="liberar()">
. Take a look here (http://jsfiddle.net/sFms7/) test remove the ()
and press "Run", you will see that the function does not run. This is because Javascript within HTML behaves differently. This pointer to the function will only be read/Parsed when the onload
be called.
The last problem is the positioning of the function liberar
. Here are two options. Or put inside the tag <head>
(missing in your code) along with the <style>
, or put it at the end of the body
, just before </body>
. Since it is only a function statement is indifferent where it puts, as long as it has the correct HTML tags.
(test withdraw ()
to see the code fail to hide the div)
I can’t understand what "it" is you’re trying to do.
– bfavaretto
@bfavaretto sorry if I did not explain in the correct way, what I am wanting to do: the page should open after fully loading, so that when opening any page have all the content already available after its loading.
– the flash
the flash, please prefer to edit the question instead of clarify in the comments.
– brasofilo
@brasofilo ok, sorry.
– the flash