{"id":69455,"date":"2019-12-30T16:21:37","date_gmt":"2019-12-30T10:51:37","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=69455"},"modified":"2024-04-12T14:21:48","modified_gmt":"2024-04-12T08:51:48","slug":"document-object-model","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/","title":{"rendered":"Document Object Model (DOM)"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/mobile-testing-appium-tutorials\/\" target=\"_blank\" rel=\"noreferrer noopener\">Go back to tutorial<\/a><\/p>\n\n\n<h1><strong>Learning&nbsp;Document Object Model (DOM)<\/strong><\/h1>\n<p>We may define Document Object Model (DOM) as a cross-platform and language-independent application programming interface.&nbsp; DOM treats an HTML, XHTML, or XML document as a tree structure wherein each node is an object representing a part of the document. Additionally, the objects can be manipulated programmatically and any visible changes may then be reflected in the display of the document.<\/p>\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/testing\/mobile-testing-appium\/document-object-model-dom-2\/attachment\/image-8-2\/\" rel=\"attachment wp-att-69648\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-69648 aligncenter\" src=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png\" alt=\"\" width=\"412\" height=\"259\" srcset=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png 601w, https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8-300x188.png 300w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/a><\/p>\n<p>JavaScript and JScript allows web developers create web pages with client-side interactivity. With the limited facilities for detecting user-generated events and modifying the HTML document in the first generation eventually was referred as &#8220;DOM Level 0&#8221; or &#8220;Legacy DOM.&#8221; Although no independent standard was developed for DOM Level 0, but it was partly described in the specifications for HTML 4.<\/p>\n<p>In the first place, Legacy DOM was limited in the kinds of elements that could be accessed.&nbsp;Although the Legacy DOM implementations were largely compatible since JScript was based on JavaScript. The DHTML DOM extensions were developed in parallel by each browser maker and remained incompatible. These versions of the DOM became known as the &#8220;Intermediate DOM.&#8221;<\/p>\n<h3><strong>DOM Application<\/strong><\/h3>\n<p>In order to render a document such as an HTML page, most web browsers use an internal model similar to the DOM. In the same vein, the nodes of every document are organized in a tree structure, called the DOM tree. Finally, when an HTML page is rendered in browsers, it downloads the HTML into local memory.&nbsp;Such that it automatically parses it to display the page on screen.<\/p>\n<p>When a web page is loaded, the browser creates a Document Object Model of the page, which is an object oriented representation of an HTML document. Since DOM supports navigation in any direction and allows for arbitrary modifications.Correspondingly, an implementation must at least buffer the document that has been read so far.<\/p>\n<h3><strong>Layout Engines<\/strong><\/h3>\n<p>Web browsers rely on layout engines to parse HTML into a DOM. Some layout engines, such as Trident\/MSHTML, are associated primarily or exclusively with a particular browser, such as Internet Explorer. Others, including Blink, WebKit, and Gecko. The different layout engines implement the DOM standards to varying degrees of compliance.<\/p>\n<p>Further, W3C DOM and WHATWG DOM standards are implemented in most modern browsers. Many browsers extend the standard, so care must be exercised when using them on the web where documents may be accessed by various browsers with different DOMs.<\/p>\n<p><strong>Illustration:<\/strong> The standard DOM specifies that the getElementsByTagName method in the code below must return a list of all the &lt;P&gt; elements in the document:<\/p>\n<p>var paragraphs = document.getElementsByTagName(&#8220;P&#8221;);<\/p>\n<p>\/\/ paragraphs[0] is the first &lt;p&gt; element<\/p>\n<p>\/\/ paragraphs[1] is the second &lt;p&gt; element, etc.<\/p>\n<p>alert(paragraphs[0].nodeName);<\/p>\n<h3><strong>DOM and JavaScript<\/strong><\/h3>\n<p>You must refer the illustration above, is written in JavaScript, but it uses the DOM to access the document and its elements. Not to mention, the DOM is not a programming language, but without it, the JavaScript language wouldn&#8217;t have any model or notion of web pages, HTML documents, XML documents, and their component parts. Every element in a document is a part of the document object model for that document. Therefore, they can all be accessed and manipulated using the DOM and a scripting language like JavaScript.<\/p>\n<h3><strong>Accessing DOM<\/strong><\/h3>\n<p>You don&#8217;t have to do anything special to begin using the DOM. to begin with, different browsers have different implementations of the DOM, therefore these implementations exhibit varying degrees of conformance to the actual DOM standard. But every web browser uses some document object model to make web pages accessible to script.<\/p>\n<p>When you create a script \u2013 whether it&#8217;s inline in a &lt;script&gt; element or included in the web page by means of a script loading instruction\u2013you can immediately begin using the API for the document or window elements. Your DOM programming may be something as simple as displaying an alert message by using the alert() function from the window object. Else it may use more sophisticated DOM methods to actually create new content, as in the longer example below.<\/p>\n<p>Illustration showing JavaScript to display an alert when the document is loaded (and when the whole DOM is available for use).<\/p>\n<p>&lt;body onload=&#8221;window.alert(&#8216;Welcome to my home page!&#8217;);&#8221;&gt;<\/p>\n<h3><strong>DOM Programming Interface<\/strong><\/h3>\n<p>HTML DOM methods are actions you can perform (on HTML Elements). Such that, HTML DOM properties are values (of HTML Elements) that you can set or change. Further, the HTML DOM can be accessed with JavaScript (and with other programming languages). In the DOM, all HTML elements are defined as objects. The programming interface is the properties and methods of each object.<\/p>\n<p>Following is a brief list of common APIs in web and XML page scripting using the DOM<\/p>\n<ul>\n<li>getElementById(id)<\/li>\n<li>getElementsByTagName(name)<\/li>\n<li>createElement(name)<\/li>\n<li>appendChild(node)<\/li>\n<li>innerHTML<\/li>\n<li>style.left<\/li>\n<li>setAttribute()<\/li>\n<li>getAttribute()<\/li>\n<li>addEventListener()<\/li>\n<li>content<\/li>\n<li>onload<\/li>\n<li>dump()<\/li>\n<li>scrollTo()<\/li>\n<\/ul>\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/mobile-testing-appium-tutorials\/\" target=\"_blank\" rel=\"noreferrer noopener\">Go back to tutorial<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go back to tutorial Learning&nbsp;Document Object Model (DOM) We may define Document Object Model (DOM) as a cross-platform and language-independent application programming interface.&nbsp; DOM treats an HTML, XHTML, or XML document as a tree structure wherein each node is an object representing a part of the document. Additionally, the objects can be manipulated programmatically and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[7891],"tags":[7936],"class_list":["post-69455","page","type-page","status-publish","hentry","category-mobile-testing-appium","tag-document-object-model-dom"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Document Object Model (DOM) - Mobile Testing - Vskills Tutorial<\/title>\n<meta name=\"description\" content=\"Get ready to become a Certified Mobile Testing Professional with advanced skills. Learn about Document Object Model and get certified Now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Document Object Model (DOM) - Mobile Testing - Vskills Tutorial\" \/>\n<meta property=\"og:description\" content=\"Get ready to become a Certified Mobile Testing Professional with advanced skills. Learn about Document Object Model and get certified Now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:51:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/\",\"name\":\"Document Object Model (DOM) - Mobile Testing - Vskills Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png\",\"datePublished\":\"2019-12-30T10:51:37+00:00\",\"dateModified\":\"2024-04-12T08:51:48+00:00\",\"description\":\"Get ready to become a Certified Mobile Testing Professional with advanced skills. Learn about Document Object Model and get certified Now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#primaryimage\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png\",\"width\":601,\"height\":377},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Document Object Model (DOM)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Document Object Model (DOM) - Mobile Testing - Vskills Tutorial","description":"Get ready to become a Certified Mobile Testing Professional with advanced skills. Learn about Document Object Model and get certified Now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/","og_locale":"en_US","og_type":"article","og_title":"Document Object Model (DOM) - Mobile Testing - Vskills Tutorial","og_description":"Get ready to become a Certified Mobile Testing Professional with advanced skills. Learn about Document Object Model and get certified Now!","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:51:48+00:00","og_image":[{"url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/","name":"Document Object Model (DOM) - Mobile Testing - Vskills Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#primaryimage"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png","datePublished":"2019-12-30T10:51:37+00:00","dateModified":"2024-04-12T08:51:48+00:00","description":"Get ready to become a Certified Mobile Testing Professional with advanced skills. Learn about Document Object Model and get certified Now!","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#primaryimage","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2019\/12\/Image-8.png","width":601,"height":377},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/document-object-model\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Document Object Model (DOM)"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/69455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=69455"}],"version-history":[{"count":5,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/69455\/revisions"}],"predecessor-version":[{"id":84549,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/69455\/revisions\/84549"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=69455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=69455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=69455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}