Categories
html image javascript

execute function after complete page load

I am using following code to execute some statements after page load.

 <script type="text/javascript">
window.onload = function () {
newInvite();
document.ag.src="https://www.faqcode4u.com/faq/410510/b.jpg";
}
</script>

But this code does not work properly. The function is called even if some images or elements are loading. What I want is to call the function the the page is loaded completely.