Want To Use Javascript Functions While They Are Within Window.onload
The addEventListener doesn't add events, I found that I should use window.onload = function() { // whole code here } but, when I try to use the functions that are within the win
Solution 1:
You can explicitly assign the functions to the window inside the handler.
window.addEventListener('DOMContentLoaded', () => {
window.someFn = () => {
// ...
};
someFn();
// you can also use someFn in the browser console
});
Post a Comment for "Want To Use Javascript Functions While They Are Within Window.onload"