“Load Event” Kode Jawaban

JavaScript yang mengeksekusi setelah memuat halaman

//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
});
Grepper

window.onload

window.onload = function() {
  // Some code
};
Lonely Lyrebird

document.addeventlistener ("muat", function () {

window.addEventListener('load', (event) => {
  console.log('page is fully loaded');
});

window.onload = (event) => {
  console.log('page is fully loaded');
};
inibir

Dokumen Muat JavaScript

window.onload = function() {
  // Code here
}
TC5550

Onload jendela

function load(argument) {
	// body...
}
window.onload = load;
If-dev

Jawaban yang mirip dengan “Load Event”

Pertanyaan yang mirip dengan “Load Event”

Lebih banyak jawaban terkait untuk “Load Event” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya