There is a popup say - alert(\"Hi Tuhin!\");
What are the basic differences when we use alerts with various methods and events listed below:
Hmm, this is more of a question of how/when these alerts get fired.
1) This will alert when the script
is loaded, ergo whenever your code gets that far down.
2) Not too sure which one you're trying to call here, either document.observe('dom:loaded', function(){})
which is deprecated or document.addEventListener("DOMContentLoaded", function(event){})
. The latter, which I assume is the one you meant, will fire as soon as the DOM is loaded without waiting for any CSS/images to finish.
3) window.onload
will fire after all elements have loaded in the DOM, including images and whatnot.
4) $("document).ready()
fires similarly to DOMContentLoaded
, where it will fire as soon as the DOM is loaded.
5) window.alert()
is pretty similar to using just alert()
, however calling window.alert() is a good idea if you have a function in your scope called alert
.