After using anonymous functions, and then using window.onload, the functions in window.onload are no longer executed. Why?

after using anonymous functions, and then using window.onload, the functions in window.onload are no longer executed. Why?

(function() {
    var hm = document.createElement("script");
    console.log(" == ", document.body.clientWidth);
})();
window.onload = function() {
    console.log(" == ", document.body.clientWidth);
}
Apr.21,2022

too little information, your code is correct


onload will not be executed until all the resources on the page have been loaded, and both console should be executed.


did you use ie to make a mistake.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3374f-44258.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3374f-44258.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?