Answers for "function page load in javascript"

25

javascript page load event

//two ways of executing JS code after page is loaded, use "DOMContentLoaded" when able

document.addEventListener("DOMContentLoaded", function(){
    //dom is fully loaded, but maybe waiting on images & css files
});

window.addEventListener("load", function(){
    //everything is fully loaded, don't use me if you can use DOMContentLoaded
});
Posted by: Guest on July-31-2019
1

on load page javascript

<body onload="AamirFunction();">

<script>
function AamirFunction() {
  var elmnt = document.getElementById("content");
  elmnt.scrollIntoView();
}
</script>
Posted by: Guest on December-29-2021

Code answers related to "function page load in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language