JavaScript Tutorials

+1 Tanveer Hussain · May 31, 2014
HI,,, Bucky>
I have watched all  of your javaScript tutorials ... but they are pretty much basics... so plz upload some more advanced javascript tutorials ... explaining DOM and BOM .......  

Post a Reply

Replies

Oldest  Newest  Rating
0 Ethan Fraser · June 3, 2014
A BOM is the Browser Object Model containing objects such as navigator, screen, location and document. When a developer is manipulating the BOM they are manipulating the browser itself. Using the BOM a person can manipulate the size and position of the browser as well as open or close a browser. An example would be opening a new window or closing  the current one.
<!--?prettify lang=html linenums=true?-->
window.open();ORwindow.close();

Or a better example (and a favourite trick of mine) is to change the current page that is loaded.
<!--?prettify lang=html linenums=true?-->
window.location.assign('http://www.google.com');

That will change the webpage to the Google.com page.



A DOM is the Document Object Model, this means changing or accessing the HTML document and not the browser. An excellent example of this would be the extremely JavaScript code used to get Elements by there ID name.
<!--?prettify lang=html linenums=true?-->
var varName = document.getElementById(id);

Another example would be accessing the CSS of an element and changing it.
<!--?prettify lang=html linenums=true?-->
varName.style.color = 'blue';

Not that style is a property of the DOM where as getElementById() is a method of the DOM. Another property of the DOM is innerHTML
<!--?prettify lang=html linenums=true?-->
varName.innerHTML = "This is a property example";


Hope that helped

Another note to consider is that the document Object (as demonstrated in the DOM explanation) is a property of the BOM object window. This means that
<!--?prettify lang=html linenums=true?-->
window.document.getElementById(id);

Is the same as
<!--?prettify lang=html linenums=true?-->
document.getElementById(id);

  • 1

Javascript

107,278 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators