1
I have a page that loads several tables, then organizes them in tabs.
You would be able to perform a function when all page loading is finished ?
1
I have a page that loads several tables, then organizes them in tabs.
You would be able to perform a function when all page loading is finished ?
4
You can use the event $(window).on("load"...
:
$(window).on("load", function(){
// página totalmente carregada (DOM, imagens etc.)
});
It’s quite different from $(document).ready(function()...
, that only fires when the DOM has been loaded, but there may be asynchronous elements (images, scripts) still being loaded.
It is worth remembering that the method
.load()
for the eventload
Javascript has become obsolete in jQuery 1.8 and removed from 3.0. (See documentation). Use.load()
only as shorthand ajax in jQuery (see documentation).
2
window.onload = function () { alert("Está carregado!") }
window.onload seems to be the most widely supported. In fact, some of the most modern browsers, in a sense, have replaced
document.onload
forwindow.onload
. Browser support issues are probably the reason many people are starting to use libraries like jQuery to handle verifying that the document is ready as follows:
$(document).ready(function() { /* code here */ }); $(function() { /* code here */ });
Source Brothers website
1
There are two ways to load a function after page loading, it can be by tag <body>
or by jquery
Take for example:
<body onLoad="nome_função();">
With this method, after full loading of everything inside the tag <body>
, it will run the function.
The second method would be this:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(window).on("load", function(){
//seu script aqui
})
</script>
So you specify on src from the first script I mentioned, where your jquery file is (or use the direct link to the file).
$(window).load(function(){})
didn’t work...
As the dvd said up there, it has become obsolete and in the latest version of jquery has been replaced. So to replace came the: $(window). on("load", Function(){}. I forgot this remark that was well remembered by him.
Browser other questions tagged php jquery
You are not signed in. Login or sign up in order to post.
What’s the difference between yours and this:
$(window).load(function() {})
– rbz
Oops! In the yellow part of the answer is explained.
– Sam
Jesus, slap me in the face ! Too blind ! rs
– rbz
@RBZ since you ordered, take https://i.stack.Imgur.com/tY276.jpg
– user60252
@Leocaracciolo do not know if taking the slap is worse, or be Robin ! hahahah
– rbz
@Sam how to load with pure javascript?
– Tiago
@Tiago Seria:
window.onload = function(){ // código aqui }
– Sam
@See if you can help me: https://answall.com/questions/429850/erro-em-ao-passar-valor-para-o-input-cannot-set-property-value-of-null
– Tiago
Tries that... erases what is inside the
if
and in place putinputExibeNome();
.. and remove onload from body.– Sam