Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 12-17-2015, 03:02 PM
georgeweballey13's Avatar
georgeweballey13 georgeweballey13 is offline
Contributing Member
 
Join Date: 09-26-14
Location: athens,greece
Posts: 162
iTrader: 0 / 0%
Do u know the difference between jquery $(document).ready and $(window).load ???

I thought, that there is no difference between these two. That both work and do stuff,
when the page has loaded. WRONG!!!
$(document).ready work when the DOM is ready.
That means that can be executed even when the pictures have NOT been loaded, cause the DOM is ready (the structure of the page and its elements)
But, when you need to do something, when EVERYTHING has loaded,
comes the $(window).load.
I found it out, when i needed to pass a javascript variable at the start of the page, and do something with that. I made it with $(document).ready and $(window).load

I found also this relative article. Check it out!
https://4loc.wordpress.com/2009/04/2...vs-windowload/
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 12-17-2015, 10:06 PM
anishrao anishrao is offline
Contributing Member
 
Join Date: 12-16-15
Location: India
Posts: 159
iTrader: 0 / 0%
document.ready -- fires after html document is loaded ( jquery event)
window.onload -- fires after document and images are loaded, this one fires later (after document.ready)
 
Reply With Quote
  #3  
Old 01-17-2016, 04:30 PM
indexi indexi is offline
Contributing Member
 
Join Date: 03-21-07
Posts: 74
iTrader: 0 / 0%
$(document).ready - the dom is rendered and ready for work - its jQuery function that based on few params one of them is body.onload
 
Reply With Quote
  #4  
Old 01-19-2016, 10:29 AM
hydfriends hydfriends is offline
Junior Member
 
Join Date: 12-24-15
Location: Pakistan
Posts: 19
iTrader: 0 / 0%
This is really helpful I didn't knew that thanks.
Quote:
Originally Posted by anishrao View Post
document.ready -- fires after html document is loaded ( jquery event)
window.onload -- fires after document and images are loaded, this one fires later (after document.ready)
 
Reply With Quote
  #5  
Old 01-20-2016, 08:38 AM
kayvee kayvee is offline
Contributing Member
 
Join Date: 10-07-15
Location: India
Posts: 55
iTrader: 0 / 0%
$(document).ready -It executes when HTML-Document is loaded and DOM is ready .
$(window).load - It executes when complete page is fully loaded, including all frames, objects and images .
 
Reply With Quote
  #6  
Old 02-21-2016, 09:51 PM
Anubhav-soin's Avatar
Anubhav-soin Anubhav-soin is offline
Contributing Member
 
Join Date: 02-10-16
Location: Delhi , India
Posts: 99
iTrader: 0 / 0%
Code:
$(document).ready(function() { // executes when HTML-Document is loaded and DOM is ready alert("document is ready"); }); $(window).load(function() { // executes when complete page is fully loaded, including all frames, objects and images alert("window is loaded"); }); $(document).ready(function() { // executes when HTML-Document is loaded and DOM is ready alert("document is ready"); }); $(window).load(function() { // executes when complete page is fully loaded, including all frames, objects and images alert("window is loaded"); });
Below given are all equivalent:
Code:
$(function(){ }); jQuery(document).ready(function(){ }); $(document).ready(function(){ }); $(document).on('ready', function(){ })
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to load js widget via jquery .load() kontrol Coding Forum 2 09-13-2014 12:39 AM
tring to use jquery load() and click() together kontrol Coding Forum 2 12-25-2012 09:50 PM
Jquery Window Problem AmbaKaramba Coding Forum 2 11-22-2010 05:46 AM
way to autoclose a window after load xmsmmgrs Coding Forum 5 03-13-2010 12:21 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 05:33 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC