Understanding the Document Object Model - 13
- Posted: Aug 06, 2012 at 10:29 AM
- 23,488 Views
- 6 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
In this video, we discuss the Document Object Model, explaining how the web browser parses and creates the DOM from HTML5 code, the purpose of the window and document objects, the built-in API functions for accessing parts of the DOM, and more.
Already have a Channel 9 account? Please sign in
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Thanks for this video, it explains a lot.
Bob, another option to window.onload event would be to declare the JS file at the bottom of the HTML page. In that case first DOM will get loaded and then JS. I'm not sure whether its a right approach, but I have seen many HTML pages with JS declared in the bottom half. Can you please clarify on this?
HonraoPrasad, its good idea to put any other script or style below html, because to increase performance of the page loading, such that when page gets loaded it can then be configured to.
Re-opening this closed thread ...
Thank you Bob,
I have a question.
document.getElementById('clickMe').onclick = runTheExample;
//why is runTheExample, not runTheExample()?
When should I put a (), and when I shouldn't put () ?
Thank you!
Best,
Yumiko
@Yumikokk: Great question. The open-close parenthesis ( ) operator tells the JavaScript execution engine to EXECUTE THE FUNCTION NOW. PULL THE TRIGGER! However, without the parenthesis, we're merely pointing to a function. So, in that code, we're saying WHEN someone performs a click on the element called clickMe, THEN pull the trigger.
If we put parenthesis on that line:
document.getElementById('clickMe').onclick = runTheExample();
... then we will fire the function right away. That's not what we want. We want to fire it off when the clickMe is clicked.
Does that help?
Remove this comment
Remove this thread
close