I need to know how to call functions js because I do not know how it is done but that it is different from onchange or onclick. The only documentation I have found has been for no answer to my question.
I need to know how to call functions js because I do not know how it is done but that it is different from onchange or onclick. The only documentation I have found has been for no answer to my question.
If possible, using the event onload
, it will be executed when the page is finished loading, example:
function My_onLoad() {
alert("Hola mundo!!");
}
<body onload="My_onLoad()">
</body>
I remain attentive to your comments or concerns, Greetings! ;))
To load the function at the time of loading the page you just have to use the onload method of javascrpt I leave the example:
function holamundo(){
console.log("Hola Mundo");
}
<body onload="holamundo()">
</body>
Alternatively to the given answers, you can use a <script>
tag before closing the </body>
.
<body>
Aquí va tu contenido html y luego de eso un elemento script.
<script>
// este es un bloque de código que se ejecuta después de que se
// cargo todo el documento.
alert('hola mundo');
</script>
<!-- la idea es no agregar mas elementos aquí -->
</body>