SlideShare a Scribd company logo
Team Emertxe
www.webstackacademy.com
Browser Object Model (BOM)
JavaScript
www.webstackacademy.com ‹#›www.webstackacademy.com
JavaScript BOM
(Introduction)
BOM
• The Browser Object Model (BOM) is used to interact with the browser.
• These BOM provides access to the various characteristics of a browser (Browser
window itself, Screen characteristics, Browser history etc…)
• The default object of browser is window means we can call all the functions of
window by specifying window or directly.
• If a document contain frames (<iframe> tags), the browser creates one window
object for the HTML document, and one additional window object for each frame.
Example :
window.alert("Hello World");
DOM and BOM - Differences
Document Object Model (DOM) Browser Object Model (BOM)
• DOM, the document object model, which
represents the contents of the web page. We
can manipulate it using JavaScript.
• All the objects are arranged as tree structure.
There are various APIs provided to access and
manipulate the document.
• W3C Recommendation. Goes beyond HTML,
supports XML and XHTML as well.
Functionality wise DOM is different.
• The BOM operates one level above the web page
which includes browser attributes (ex: Location)
and the page becomes a child of Browser.
• All global JavaScript objects, functions and variables
automatically become members of the window
object.
• Using BOM, we can modify, move the window or
can change the text in status bar, read the current
URL, go back or forward of the current page
BOM – Object Hierarchy
www.webstackacademy.com ‹#›www.webstackacademy.com
BOM - Window
(Basic BOM Window APIs)
BOM – Window Size
<script>
var w = window.innerWidth;
var h = window.innerHeight
var x = document.getElementById("ex");
x.innerHTML = “Width: " + w + “<br>” + " Height: " + h;
</script>
Property Description
window.innerHeight The browser's client area height including scrollbars
window.innerWidth The browser's client area width including scrollbars
There are two properties to determine the size of window:
BOM – Window Methods
Method to open a new window with some parameters
Method Description
window.alert() Displays alert box with OK button.
window.confirm() Displays a confirmation dialog box with OK and cancel button.
window.prompt() Displays a prompt dialog box to get user input
window.close() Closes the window
window.moveTo() Move the current window
window.resizeTo() Resize the current window
BOM – Window.open() Method
Method & Description
window.open(URL, name, specs, replace)
URL:
• Specifies the URL of the page to open.
Name:
• Specifies the target attribute or the name of the window.
• Values supported (ex: blank)
Specs:
• Comma separated values, loads of options
• Example – Height
Replace:
• Specifies whether the URL creates a new entry or replaces the current entry in the history list.
• True and False values are supported
BOM – Window Screen Methods
The screen object contains information about visitor’s screen
Property Description
availHeight() Returns the height of the screen
availWidth() Returns the width of the screen
colorDepth() Returns the bit depth of the color palette for displaying image
height() Returns the total height of the screen
width() Returns the total width of the screen
pixelDepth() Returns the color resolution of the screen
www.webstackacademy.com ‹#›www.webstackacademy.com
BOM – Navigator
(BOM Browser related APIs)
BOM – Navigator Object
The window.navigator provides information about the browser. There is no standard
implementation for this, often most of the information is misleading. Don’t rely on it, just
learn 
Property Description
appCodeName The code name of the browser
appName The name of the browser
appVersion Specifies the version of the browser
userAgent Returns the user agent
language Returns the language of the browser.
cookieEnabled Returns true if cookie is enabled otherwise false
platform Browser platform (OS)
BOM – Navigator Object
<script>
document.write("Navigator App Name : "+ navigator.appName + "<br>");
document.write("Navigator App Code Name : "+ navigator.appCodeName + "<br>");
document.write("Navigator App Version : "+ navigator.appVersion + "<br>");
document.write("Navigator User Agent : "+ navigator.userAgent + "<br>");
document.write("navigator Language : "+ navigator.language + "<br>");
document.write("Navigator Platform : "+ navigator.platform + "<br>");
document.write("Navigator Cookie Enabled : "+ navigator.cookieEnabled + "<br>");
</script>
www.webstackacademy.com ‹#›www.webstackacademy.com
BOM – History
(BOM User history related APIs)
BOM – History Object
• The JavaScript history object represents an array of URL visited by the user.
• The History object is a read-only array of URL.
• We can load previous, forward or any particular page using history object.Method Description
back() Loads the previous URL in the history list
forward() Loads the next URL in the history list
go() Loads specific page in the history list
length Number of elements in the history list
BOM – History Object
window.history.forward() ; // Forward
window.history.back(); // Back
window.history.go(-5); // Go back 5 times
window.history.go(2); // Forward two times
window.history.go(window.history.length-1); // Go last item
www.webstackacademy.com ‹#›www.webstackacademy.com
BOM – Location
(BOM User location related APIs)
BOM – Location Object
Location object provides general access properties of the document
Property Description
window.location.href The full URL of the currently loaded page (ex: http://www.ABC.com)
window.location.hostname Returns the domain name of the web host (ex: www.ABC.com)
window.location.pathname Returns path and filename of the current page
window.location.protocol Returns web protocol used (http or https)
window.location.hash Sets or returns the anchor(#) part of URL (ex: www.ABC.com#print)
window.location.port Sets or returns the port number of a URL (Typically for HTTP 80 is
used, it can be configured / changed)
BOM – Location Methods
Location object provides following methods to load / unload new documents
Property Description
window.location.assign() Loads a new document
window.location.reload() Reloads the current document
window.location.replace() Replace the current document with a new one
www.webstackacademy.com ‹#›www.webstackacademy.com
BOM – Timing Events
(BOM Timer APIs)
BOM Timing Events
Method Description
setTimeout(function,duration) This function calls function after duration milliseconds from
now
setInterval(function,duration) This function calls function after every duration milliseconds
clearTimeout(timeout) This function calls clears any timer set by the setTimeout()
functions
• The window object supports events for setting Time Intervals.
• These Time Intervals are called Timing events.
www.webstackacademy.com ‹#›www.webstackacademy.com
Cookies
(Storing meta information using BOM)
Cookies – What?
• A Cookie is a small piece of text data set by a web server that resides
on the client's machine.
• The Cookie is stored on the user's computer, it does not require any
server space .
• A website can set and read only its own cookies. Primarily cookies are
used for user identity management.
• The document.cookie property is used while dealing with
cookies
Cookies – Types & Uses
Cookies
Session Cookies
Persistent Cookies
Set with expiry field. Destroyed when the user quits the browser.
They are set with a expiry date. Maintained until the date.
Cookies can be used for: Authentication, Session Tracking, Remember specific information about the user
like his name, password, last visited date etc
Cookie Attributes
Token Description
username=value User identification information
expires=date Set the expiration date in form of UTC (Co-ordinated Universal Time). If you don’t set
cookies are deleted when the browser get closed (Session cookies).
domain=domain The domain for which the cookie is valid. In case is it not specified, the hostname of
the server is used
path=path This specifies the path where the cookie is valid. By default is will be set as “/”
directory, for specific sub-domains the path need to be added
secure Setting secure option will make the cookie to be returned only over encrypted
HTTPS connection. This way it will protect other scripts accessing the cookie, which
will enhance the security.
Setting Cookies - Example
Syntax :
name1=value1;name2=value2;name3=value3;
Example:
document.cookie=“username=WSA;expires=“Mon,18-Mar-2017 09:00:00 UTC”;
path=/;domain=example.com;"
Important note:
• The document.cookie gives valid value only when the page is hosted from a server (in Chrome).
• Use Bracket for testing cookies and host pages from XAMPP web server.
Cookie Limitations
• Cookies can identify the computer being used , not the individual.
• Cookies cannot access by any other computer except the visitor's
computer that created the cookie.
• The total number of cookies a browser can store at one time from
one particular site is limited to 20.
• Each cookie is limited to about 4000 characters.
WebStack Academy
#83, Farah Towers,
1st Floor, MG Road,
Bangalore – 560001
M: +91-809555 7332
E: training@webstackacademy.com
WSA in Social Media:
Ad

More Related Content

What's hot (20)

Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
ShahDhruv21
 
jQuery
jQueryjQuery
jQuery
Jay Poojara
 
Java script
Java scriptJava script
Java script
Shyam Khant
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
Mindy McAdams
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
T11 Sessions
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Java script
Java scriptJava script
Java script
Abhishek Kesharwani
 
Javascript
JavascriptJavascript
Javascript
guest03a6e6
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
Webtech Learning
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
jQuery
jQueryjQuery
jQuery
Dileep Mishra
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
sentayehu
 
CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3
Jaimin Brahmbhatt
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
Rachel Andrew
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
ShahDhruv21
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
Mindy McAdams
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
T11 Sessions
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
sentayehu
 
CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3
Jaimin Brahmbhatt
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 

Similar to JavaScript - Chapter 13 - Browser Object Model(BOM) (20)

Java script Advance
Java script   AdvanceJava script   Advance
Java script Advance
Jaya Kumari
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
Lena Petsenchuk
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
Subhas Malik
 
Web Standards Support in WebKit
Web Standards Support in WebKitWeb Standards Support in WebKit
Web Standards Support in WebKit
Joone Hur
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
Tommy Vercety
 
Javascript
Javascript Javascript
Javascript
poojanov04
 
Javascript 1
Javascript 1Javascript 1
Javascript 1
pavishkumarsingh
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using Javascript
Bansari Shah
 
INTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGINTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMING
Prof Ansari
 
19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx
VatsalJain39
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
Jussi Pohjolainen
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
Anup Hariharan Nair
 
ASP.NET Lecture 2
ASP.NET Lecture 2ASP.NET Lecture 2
ASP.NET Lecture 2
Julie Iskander
 
ASP.Net Presentation Part3
ASP.Net Presentation Part3ASP.Net Presentation Part3
ASP.Net Presentation Part3
Neeraj Mathur
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applications
dcoletta
 
Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
Sasidhar Kothuru
 
Active server pages
Active server pagesActive server pages
Active server pages
mcatahir947
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 
A View about ASP .NET and their objectives
A View about ASP .NET and their objectivesA View about ASP .NET and their objectives
A View about ASP .NET and their objectives
Department of Computer Science, Bharathidasan University, Tiruchirappalli
 
19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptx19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptx
ssuser4a97d3
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script Advance
Jaya Kumari
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
Subhas Malik
 
Web Standards Support in WebKit
Web Standards Support in WebKitWeb Standards Support in WebKit
Web Standards Support in WebKit
Joone Hur
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
Tommy Vercety
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using Javascript
Bansari Shah
 
INTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGINTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMING
Prof Ansari
 
19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx
VatsalJain39
 
ASP.Net Presentation Part3
ASP.Net Presentation Part3ASP.Net Presentation Part3
ASP.Net Presentation Part3
Neeraj Mathur
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applications
dcoletta
 
Active server pages
Active server pagesActive server pages
Active server pages
mcatahir947
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 
19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptx19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptx
ssuser4a97d3
 
Ad

More from WebStackAcademy (20)

Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement Journey
WebStackAcademy
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per Second
WebStackAcademy
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer Course
WebStackAcademy
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
WebStackAcademy
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick Off
WebStackAcademy
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online Portfolio
WebStackAcademy
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
WebStackAcademy
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
WebStackAcademy
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
WebStackAcademy
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
WebStackAcademy
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
WebStackAcademy
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
JavaScript - Chapter 1 - Problem Solving
 JavaScript - Chapter 1 - Problem Solving JavaScript - Chapter 1 - Problem Solving
JavaScript - Chapter 1 - Problem Solving
WebStackAcademy
 
Webstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement JourneyWebstack Academy - Course Demo Webinar and Placement Journey
Webstack Academy - Course Demo Webinar and Placement Journey
WebStackAcademy
 
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per SecondWSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Scaling Web Service to Handle Millions of Requests per Second
WebStackAcademy
 
WSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer CourseWSA: Course Demo Webinar - Full Stack Developer Course
WSA: Course Demo Webinar - Full Stack Developer Course
WebStackAcademy
 
Career Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
WebStackAcademy
 
Webstack Academy - Internship Kick Off
Webstack Academy - Internship Kick OffWebstack Academy - Internship Kick Off
Webstack Academy - Internship Kick Off
WebStackAcademy
 
Building Your Online Portfolio
Building Your Online PortfolioBuilding Your Online Portfolio
Building Your Online Portfolio
WebStackAcademy
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
WebStackAcademy
 
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and AuthorizationAngular - Chapter 9 - Authentication and Authorization
Angular - Chapter 9 - Authentication and Authorization
WebStackAcademy
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase IntegrationAngular - Chapter 6 - Firebase Integration
Angular - Chapter 6 - Firebase Integration
WebStackAcademy
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
WebStackAcademy
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
WebStackAcademy
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
WebStackAcademy
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
JavaScript - Chapter 1 - Problem Solving
 JavaScript - Chapter 1 - Problem Solving JavaScript - Chapter 1 - Problem Solving
JavaScript - Chapter 1 - Problem Solving
WebStackAcademy
 
Ad

Recently uploaded (20)

AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 

JavaScript - Chapter 13 - Browser Object Model(BOM)

  • 3. BOM • The Browser Object Model (BOM) is used to interact with the browser. • These BOM provides access to the various characteristics of a browser (Browser window itself, Screen characteristics, Browser history etc…) • The default object of browser is window means we can call all the functions of window by specifying window or directly. • If a document contain frames (<iframe> tags), the browser creates one window object for the HTML document, and one additional window object for each frame. Example : window.alert("Hello World");
  • 4. DOM and BOM - Differences Document Object Model (DOM) Browser Object Model (BOM) • DOM, the document object model, which represents the contents of the web page. We can manipulate it using JavaScript. • All the objects are arranged as tree structure. There are various APIs provided to access and manipulate the document. • W3C Recommendation. Goes beyond HTML, supports XML and XHTML as well. Functionality wise DOM is different. • The BOM operates one level above the web page which includes browser attributes (ex: Location) and the page becomes a child of Browser. • All global JavaScript objects, functions and variables automatically become members of the window object. • Using BOM, we can modify, move the window or can change the text in status bar, read the current URL, go back or forward of the current page
  • 5. BOM – Object Hierarchy
  • 7. BOM – Window Size <script> var w = window.innerWidth; var h = window.innerHeight var x = document.getElementById("ex"); x.innerHTML = “Width: " + w + “<br>” + " Height: " + h; </script> Property Description window.innerHeight The browser's client area height including scrollbars window.innerWidth The browser's client area width including scrollbars There are two properties to determine the size of window:
  • 8. BOM – Window Methods Method to open a new window with some parameters Method Description window.alert() Displays alert box with OK button. window.confirm() Displays a confirmation dialog box with OK and cancel button. window.prompt() Displays a prompt dialog box to get user input window.close() Closes the window window.moveTo() Move the current window window.resizeTo() Resize the current window
  • 9. BOM – Window.open() Method Method & Description window.open(URL, name, specs, replace) URL: • Specifies the URL of the page to open. Name: • Specifies the target attribute or the name of the window. • Values supported (ex: blank) Specs: • Comma separated values, loads of options • Example – Height Replace: • Specifies whether the URL creates a new entry or replaces the current entry in the history list. • True and False values are supported
  • 10. BOM – Window Screen Methods The screen object contains information about visitor’s screen Property Description availHeight() Returns the height of the screen availWidth() Returns the width of the screen colorDepth() Returns the bit depth of the color palette for displaying image height() Returns the total height of the screen width() Returns the total width of the screen pixelDepth() Returns the color resolution of the screen
  • 12. BOM – Navigator Object The window.navigator provides information about the browser. There is no standard implementation for this, often most of the information is misleading. Don’t rely on it, just learn  Property Description appCodeName The code name of the browser appName The name of the browser appVersion Specifies the version of the browser userAgent Returns the user agent language Returns the language of the browser. cookieEnabled Returns true if cookie is enabled otherwise false platform Browser platform (OS)
  • 13. BOM – Navigator Object <script> document.write("Navigator App Name : "+ navigator.appName + "<br>"); document.write("Navigator App Code Name : "+ navigator.appCodeName + "<br>"); document.write("Navigator App Version : "+ navigator.appVersion + "<br>"); document.write("Navigator User Agent : "+ navigator.userAgent + "<br>"); document.write("navigator Language : "+ navigator.language + "<br>"); document.write("Navigator Platform : "+ navigator.platform + "<br>"); document.write("Navigator Cookie Enabled : "+ navigator.cookieEnabled + "<br>"); </script>
  • 14. www.webstackacademy.com ‹#›www.webstackacademy.com BOM – History (BOM User history related APIs)
  • 15. BOM – History Object • The JavaScript history object represents an array of URL visited by the user. • The History object is a read-only array of URL. • We can load previous, forward or any particular page using history object.Method Description back() Loads the previous URL in the history list forward() Loads the next URL in the history list go() Loads specific page in the history list length Number of elements in the history list
  • 16. BOM – History Object window.history.forward() ; // Forward window.history.back(); // Back window.history.go(-5); // Go back 5 times window.history.go(2); // Forward two times window.history.go(window.history.length-1); // Go last item
  • 17. www.webstackacademy.com ‹#›www.webstackacademy.com BOM – Location (BOM User location related APIs)
  • 18. BOM – Location Object Location object provides general access properties of the document Property Description window.location.href The full URL of the currently loaded page (ex: http://www.ABC.com) window.location.hostname Returns the domain name of the web host (ex: www.ABC.com) window.location.pathname Returns path and filename of the current page window.location.protocol Returns web protocol used (http or https) window.location.hash Sets or returns the anchor(#) part of URL (ex: www.ABC.com#print) window.location.port Sets or returns the port number of a URL (Typically for HTTP 80 is used, it can be configured / changed)
  • 19. BOM – Location Methods Location object provides following methods to load / unload new documents Property Description window.location.assign() Loads a new document window.location.reload() Reloads the current document window.location.replace() Replace the current document with a new one
  • 21. BOM Timing Events Method Description setTimeout(function,duration) This function calls function after duration milliseconds from now setInterval(function,duration) This function calls function after every duration milliseconds clearTimeout(timeout) This function calls clears any timer set by the setTimeout() functions • The window object supports events for setting Time Intervals. • These Time Intervals are called Timing events.
  • 23. Cookies – What? • A Cookie is a small piece of text data set by a web server that resides on the client's machine. • The Cookie is stored on the user's computer, it does not require any server space . • A website can set and read only its own cookies. Primarily cookies are used for user identity management. • The document.cookie property is used while dealing with cookies
  • 24. Cookies – Types & Uses Cookies Session Cookies Persistent Cookies Set with expiry field. Destroyed when the user quits the browser. They are set with a expiry date. Maintained until the date. Cookies can be used for: Authentication, Session Tracking, Remember specific information about the user like his name, password, last visited date etc
  • 25. Cookie Attributes Token Description username=value User identification information expires=date Set the expiration date in form of UTC (Co-ordinated Universal Time). If you don’t set cookies are deleted when the browser get closed (Session cookies). domain=domain The domain for which the cookie is valid. In case is it not specified, the hostname of the server is used path=path This specifies the path where the cookie is valid. By default is will be set as “/” directory, for specific sub-domains the path need to be added secure Setting secure option will make the cookie to be returned only over encrypted HTTPS connection. This way it will protect other scripts accessing the cookie, which will enhance the security.
  • 26. Setting Cookies - Example Syntax : name1=value1;name2=value2;name3=value3; Example: document.cookie=“username=WSA;expires=“Mon,18-Mar-2017 09:00:00 UTC”; path=/;domain=example.com;" Important note: • The document.cookie gives valid value only when the page is hosted from a server (in Chrome). • Use Bracket for testing cookies and host pages from XAMPP web server.
  • 27. Cookie Limitations • Cookies can identify the computer being used , not the individual. • Cookies cannot access by any other computer except the visitor's computer that created the cookie. • The total number of cookies a browser can store at one time from one particular site is limited to 20. • Each cookie is limited to about 4000 characters.
  • 28. WebStack Academy #83, Farah Towers, 1st Floor, MG Road, Bangalore – 560001 M: +91-809555 7332 E: [email protected] WSA in Social Media: