Difference Between Jquery $(window).load Vs Window.onload
I have the following code: function initialize() { var mapOptions = { center: new google.maps.LatLng(53.743317, -0.331004), zoom: 12 }; var map = new google.maps.Map(
Solution 1:
You haven't actually invoked loadScript
in the $(window).load()
version - you've just created a "void" expression that evaluates to a reference to that function.
Do either:
$(window).load(function() {
loadScript(); // NB: parentheses
})
or:
$(window).load(loadScript);
That said, you perhaps want $(document).ready()
rather than $(window).load()
Solution 2:
in your jquery script you don't invoke the loadScript method... Use:
$( window ).load(function() {
loadScript();
});
Solution 3:
The $(window).load execute when all DOM is ready including images. That means if our web page has completely loaded including image then $(window).load function will call.
$(window).load(function() {
// script
})
for more detail about $(document).ready vs $(window).load vs window.onload click on
http://www.delhincrjob.com/blog/what-is-document-ready-vs-window-load-vs-window-onload/
Post a Comment for "Difference Between Jquery $(window).load Vs Window.onload"