I write document.onload code inside my head tag.. but it doesn't seems to work.
here is my code..
<head>
<script>
document.onload = function () {
alert("Window Loaded...!!");
}
</script>
</head>
But if i replace with window.onload it perfectly works!!
What is the problem? Am I doing something wrong ??
As far as I'm aware, the closest you can come to your method is:
document.addEventListener('DOMContentLoaded', function () {
/* your logic here */
});
The problem you have is document may not have a method of onload for a particular browser. Luckily! The window does in most cases. :) Give that a try for your JavaScript invocation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With