U told me that $(document).load isn't a built-In, but how can explain this——U see that document has a onload property, which can be attached with a function:
document.onload = function () { }
And what's more, I cannot find onready for document?
JavaScript and dom objects are expando objects. This mean you can add any property you want. I can add a onfoo method to the document, but the browser will not know about it:
document.onfoo = function(){alert('hi');};
this does not make onfoo an event the browser will fire.
note: to know what events a particular browser will fire, you need to read the docs for that browser. for example, IE will not only vary by version, but also by what mode (standards, IE7, IE8, etc).
unlike c# intellsense which uses reflection, javascript intellisense, just has a file defining browser objects and methods.
as I said, its different for every browser. read the docs on the browsers you are interested in supporting. while it's best to stick to the w3c defined events, this requires a standards complaint browser. if you read the standard, you will note that a standards
based browser supports adding custom events.
standards based events:
http://www.w3.org/TR/DOM-Level-3-Events/
for chrome, safari (webkit browsers) details try:
https://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/SafariJSProgTopics/WebKitJavaScript.html#//apple_ref/doc/uid/TP40001483
because its designed for IE. with IE all dom objects implment an base dom element (object), and this object has a onload property. vs2012 will give you a onload for a td, span element or any dom element.
the property was only used by body, window, img, frame, iframe, applet and object (com) dom elements. no modern browser would do this, but it would be a breaking change for IE. becuase it exists you can set the property to your hearts content, but only certain
element fire it. as the dom elements are expando you can add any property you want.
but if you write for w3c dom, you should not use the onload syntax, you use element.addEventListener().
note: you will find onActivate which only fires for <applet> and <object> elements.
bruce (sqlwork.com)
Marked as answer by ToughMan on Jan 28, 2013 07:49 AM
ToughMan
Participant
1490 Points
635 Posts
Re: Why document.load isn't raised?
Jan 26, 2013 10:35 AM|LINK
Another question——
U told me that $(document).load isn't a built-In, but how can explain this——U see that document has a onload property, which can be attached with a function:
document.onload = function () { }And what's more, I cannot find onready for document?
Can you explain more?
ToughMan
Participant
1490 Points
635 Posts
Re: Why document.load isn't raised?
Jan 26, 2013 10:40 AM|LINK
Find this in VS2010 in Web App.
ToughMan
Participant
1490 Points
635 Posts
Re: Why document.load isn't raised?
Jan 26, 2013 10:41 AM|LINK
???
But document has onload, just like what I said to Steven Cheng……???
bruce (sqlwo...
All-Star
36644 Points
5432 Posts
Re: Why document.load isn't raised?
Jan 26, 2013 09:56 PM|LINK
JavaScript and dom objects are expando objects. This mean you can add any property you want. I can add a onfoo method to the document, but the browser will not know about it:
document.onfoo = function(){alert('hi');};
this does not make onfoo an event the browser will fire.
note: to know what events a particular browser will fire, you need to read the docs for that browser. for example, IE will not only vary by version, but also by what mode (standards, IE7, IE8, etc).
unlike c# intellsense which uses reflection, javascript intellisense, just has a file defining browser objects and methods.
ToughMan
Participant
1490 Points
635 Posts
Re: Why document.load isn't raised?
Jan 27, 2013 02:16 AM|LINK
So "document" has no onload property in fact, and it's VS2012 is cheating me??/!
ToughMan
Participant
1490 Points
635 Posts
Re: Why document.load isn't raised?
Jan 27, 2013 02:32 AM|LINK
By which document can I see whether functions belong to built-In?
VS2012 is cheating us:(
bruce (sqlwo...
All-Star
36644 Points
5432 Posts
Re: Why document.load isn't raised?
Jan 27, 2013 07:51 PM|LINK
as I said, its different for every browser. read the docs on the browsers you are interested in supporting. while it's best to stick to the w3c defined events, this requires a standards complaint browser. if you read the standard, you will note that a standards based browser supports adding custom events.
standards based events:
http://www.w3.org/TR/DOM-Level-3-Events/
for chrome, safari (webkit browsers) details try:
https://developer.apple.com/library/safari/#documentation/AppleApplications/Conceptual/SafariJSProgTopics/WebKitJavaScript.html#//apple_ref/doc/uid/TP40001483
for IE 9/10:
http://msdn.microsoft.com/en-us/library/hh772374(v=vs.85).aspx
ToughMan
Participant
1490 Points
635 Posts
Re: Why document.load isn't raised?
Jan 28, 2013 01:49 AM|LINK
Have u tried VS2012? why it gives me "onload" for document??????????
bruce (sqlwo...
All-Star
36644 Points
5432 Posts
Re: Why document.load isn't raised?
Jan 28, 2013 04:26 AM|LINK
because its designed for IE. with IE all dom objects implment an base dom element (object), and this object has a onload property. vs2012 will give you a onload for a td, span element or any dom element.
the property was only used by body, window, img, frame, iframe, applet and object (com) dom elements. no modern browser would do this, but it would be a breaking change for IE. becuase it exists you can set the property to your hearts content, but only certain element fire it. as the dom elements are expando you can add any property you want.
but if you write for w3c dom, you should not use the onload syntax, you use element.addEventListener().
note: you will find onActivate which only fires for <applet> and <object> elements.