{"id":6100,"date":"2022-09-19T04:28:15","date_gmt":"2022-09-19T04:28:15","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=6100"},"modified":"2022-09-19T06:06:01","modified_gmt":"2022-09-19T06:06:01","slug":"bom-browser-object-model-in-javascript","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/","title":{"rendered":"BOM (Browser Object Model) In Javascript"},"content":{"rendered":"<h2>Introduction:<\/h2>\n<p>The Browser Object Model allows JavaScript to access several pieces of information about a browser including history, screen size, location, and cookies. The Document Object is made up of objects used to modify the documents&#8217; properties and methods loaded into the browser window.<\/p>\n<p><strong>Some of the important BOM(Browser Object Model) objects:<\/strong><\/p>\n<ul>\n<li>window<\/li>\n<li>window.screen<\/li>\n<li>window.history<\/li>\n<li>Window.location<\/li>\n<li>window.navigator<\/li>\n<\/ul>\n<ol>\n<li><strong>Window object:<\/strong><br \/>\nThe window object is a representation of the browser&#8217;s window. The window object includes all of the global JavaScript objects as members.Window object method:-<br \/>\n<code>alert(): The browser can invoke a system dialog to display information to the user.<br \/>\nEx: alert(\u201cHello, Welcome Back\u201d);<\/code><code>getComputedStyle(): This method returns an object containing the values of all CSS properties of an element.<br \/>\nEx: Var fontFamily=<br \/>\ngetComputedStyle(document.getElementsByClassName<br \/>\n('btnstyle')[1])  .getPropertyValue('font-family');<\/code><\/p>\n<p><strong>Window object Properties:<\/strong><br \/>\n<code>inner width:<br \/>\nEx:let width = window.innerWidth;<br \/>\nWindow History Object<br \/>\nlet length = window.history.length;<\/code><\/li>\n<li><strong>Window.history<\/strong><br \/>\nThe history object represents a user&#8217;s web browsing history as an array of the URLs that the user visited.There are three ways to switch between pages in the history stack using the history object:<\/p>\n<ul>\n<li>back()<\/li>\n<li>forward()<\/li>\n<li>go()<\/li>\n<\/ul>\n<p><strong>back():<\/strong> The previous URL will be displayed using this technique. This functionality will be the same as using the browser&#8217;s back button.<br \/>\nEX:window.history.back();<\/p>\n<p><strong>forward():<\/strong> This method will open the next URL in the browser history.<br \/>\nEX: window.history.forward()<\/p>\n<p><strong>go():<\/strong> This method will open the specific URL in the browser history.<br \/>\nEX:<br \/>\n&lt;button id=&#8221;cancelchanges&#8221; onclick=&#8221;return CancelChanges()&#8221; ;&gt;<br \/>\nCancel<br \/>\n&lt;\/button&gt;<br \/>\n\/\/To Step Back to the previous Page:<br \/>\nfunction CancelChanges()<br \/>\n{<br \/>\nwindow.history.go(-1);<br \/>\nreturn false;<br \/>\n}<br \/>\n\/\/To Refresh Page<br \/>\nwindow.history.go(0);<\/li>\n<li><strong>Window.screen:<\/strong> Javascript window screen object contains information about the user\u2019s screen. This object provides information about the user&#8217;s display outside the browser window, including pixel width and height.<br \/>\n<strong>screen.width\u2013<\/strong> This property will return the width of the user\u2019s screen in pixels.<br \/>\nEx: var width = screen.width;<strong>screen.height\u2013 <\/strong>This property will return the height of the user\u2019s screen in pixels.<br \/>\nEx: var height = screen.height;<\/li>\n<li><strong>Window.location:<\/strong> The location object, like the document, history, and screen objects, is a property of the window object that contains the relevant information about the available URL.EX: Onclick button moves the user to a specific URL<br \/>\n<code>&lt;button id=\"Moveuser\" onclick=\"Moveuser()\" ;&gt;<br \/>\nBack<br \/>\n&lt;\/button&gt;<br \/>\nfunction Moveuser()<br \/>\n{<br \/>\n\/\/relativePath<br \/>\nwindow.location=\u201d\/homepage\u201d;<br \/>\n}<\/code><strong>window.location.href:<\/strong> This property will return the URL of the current webpage.<br \/>\nEX:<br \/>\n<code> &lt;button type=\"button\" onclick=\"getURL();\"&gt;Get Page URL&lt;\/button&gt;<br \/>\nfunction getURL() {<br \/>\nalert(\"The URL of this page is: \" + window.location.href);<br \/>\n}<\/code><br \/>\n<strong>Window.location.reload:<\/strong><br \/>\nEX: Click button user gets the first warning and on click on ok button page is reloaded<br \/>\n<code> &lt;button id=\"Moveuser\" onclick=\"refreshpage()\" ;&gt;ReloadPage&lt;\/button&gt;<br \/>\nfunction refreshpage()<br \/>\n{<br \/>\nswal({<br \/>\ntitle: \"warning\",<br \/>\ntext: \"do you really want to refresh the page\u201d,<br \/>\ntype: \"warning\",<br \/>\nicon: \"warning\",<br \/>\n}, function () {<br \/>\nlocation.reload();<br \/>\n});<br \/>\n}<\/code><\/li>\n<li><strong>Window.navigator:<\/strong> It will contain information about the visitor\u2019s browser.<br \/>\n<strong>navigator.appCodeName:<\/strong> The appName property returns the application name of the browser:<br \/>\nEx: var appname=navigator.appName;<strong>navigator.onLine:<\/strong> The navigator.onLine property to detect whether the browser is online or offline.Ex:<br \/>\n<code>&lt;button type=\"button\" onclick=\"checkConnectionStatus();\"&gt;Check Connection Status&lt;\/button&gt;<br \/>\nfunction checkConnectionStatus() {<br \/>\nif(navigator.onLine) {<br \/>\nalert(\"Application is online.\");<br \/>\n} else {<br \/>\nalert(\"Application is offline.\");<br \/>\n}}<\/code><\/p>\n<p>Ex: click the browser back button it will reload the page:<\/p>\n<p><code>window.addEventListener(\"pageshow\", function (event) {<br \/>\nvar historyTraversal = event.persisted ||<br \/>\n(typeof window.performance != \"undefined\" &amp;&amp;<br \/>\nwindow.performance.navigation.type === 2);<br \/>\nif (historyTraversal) {<br \/>\nwindow.location.reload();<br \/>\n}<br \/>\n});<\/code><\/li>\n<\/ol>\n<p><small><em>Microsoft Windows 10 is a widely used operating system in computers all over the world. If you have skills in Microsoft Windows 10 then you can get a <a href=\"https:\/\/www.studysection.com\/windows-10-advanced\">Windows 10 Certification<\/a> from StudySection which can help you in getting hired. A beginner level certification exam for newbies and an advanced level certification exam for experts is available on StudySection.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: The Browser Object Model allows JavaScript to access several pieces of information about a browser including history, screen size,<\/p>\n","protected":false},"author":1,"featured_media":6102,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[805,199],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>BOM (Browser Object Model) In Javascript - SS Blog<\/title>\n<meta name=\"description\" content=\"The Browser Object Model allows JavaScript to access several pieces of information about a browser, including history.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"BOM (Browser Object Model) In Javascript - SS Blog\" \/>\n<meta property=\"og:description\" content=\"The Browser Object Model allows JavaScript to access several pieces of information about a browser, including history.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-19T04:28:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-19T06:06:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2022\/09\/Javascript.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"BOM (Browser Object Model) In Javascript\",\"datePublished\":\"2022-09-19T04:28:15+00:00\",\"dateModified\":\"2022-09-19T06:06:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/\"},\"wordCount\":480,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"BOM\",\"JavaScript\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/\",\"url\":\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/\",\"name\":\"BOM (Browser Object Model) In Javascript - SS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2022-09-19T04:28:15+00:00\",\"dateModified\":\"2022-09-19T06:06:01+00:00\",\"description\":\"The Browser Object Model allows JavaScript to access several pieces of information about a browser, including history.\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"BOM (Browser Object Model) In Javascript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"BOM (Browser Object Model) In Javascript - SS Blog","description":"The Browser Object Model allows JavaScript to access several pieces of information about a browser, including history.","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:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"BOM (Browser Object Model) In Javascript - SS Blog","og_description":"The Browser Object Model allows JavaScript to access several pieces of information about a browser, including history.","og_url":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2022-09-19T04:28:15+00:00","article_modified_time":"2022-09-19T06:06:01+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2022\/09\/Javascript.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"BOM (Browser Object Model) In Javascript","datePublished":"2022-09-19T04:28:15+00:00","dateModified":"2022-09-19T06:06:01+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/"},"wordCount":480,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["BOM","JavaScript"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/","url":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/","name":"BOM (Browser Object Model) In Javascript - SS Blog","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2022-09-19T04:28:15+00:00","dateModified":"2022-09-19T06:06:01+00:00","description":"The Browser Object Model allows JavaScript to access several pieces of information about a browser, including history.","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/bom-browser-object-model-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"BOM (Browser Object Model) In Javascript"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":585,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6100"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=6100"}],"version-history":[{"count":5,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6100\/revisions"}],"predecessor-version":[{"id":6106,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6100\/revisions\/6106"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/6102"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=6100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=6100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=6100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}