Movatterモバイル変換


[0]ホーム

URL:


WebStackAcademy, profile picture
Uploaded byWebStackAcademy
PDF, PPTX5,064 views

JavaScript - Chapter 13 - Browser Object Model(BOM)

The document provides an extensive overview of the Browser Object Model (BOM) in JavaScript, detailing how it interacts with browser features such as the window size, navigator information, and user history. It explains various methods and properties available in BOM to manipulate browser windows, access user data, and manage cookies. Additionally, the document compares BOM with the Document Object Model (DOM) and discusses the types, uses, and limitations of cookies.

Embed presentation

Download as PDF, PPTX
Team Emertxewww.webstackacademy.comBrowser Object Model (BOM)JavaScript
www.webstackacademy.com ‹#›www.webstackacademy.comJavaScript 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 (Browserwindow itself, Screen characteristics, Browser history etc…)• The default object of browser is window means we can call all the functions ofwindow by specifying window or directly.• If a document contain frames (<iframe> tags), the browser creates one windowobject for the HTML document, and one additional window object for each frame.Example :window.alert("Hello World");
DOM and BOM - DifferencesDocument Object Model (DOM) Browser Object Model (BOM)• DOM, the document object model, whichrepresents the contents of the web page. Wecan manipulate it using JavaScript.• All the objects are arranged as tree structure.There are various APIs provided to access andmanipulate 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 pagewhich includes browser attributes (ex: Location)and the page becomes a child of Browser.• All global JavaScript objects, functions and variablesautomatically become members of the windowobject.• Using BOM, we can modify, move the window orcan change the text in status bar, read the currentURL, go back or forward of the current page
BOM – Object Hierarchy
www.webstackacademy.com ‹#›www.webstackacademy.comBOM - Window(Basic BOM Window APIs)
BOM – Window Size<script>var w = window.innerWidth;var h = window.innerHeightvar x = document.getElementById("ex");x.innerHTML = “Width: " + w + “<br>” + " Height: " + h;</script>Property Descriptionwindow.innerHeight The browser's client area height including scrollbarswindow.innerWidth The browser's client area width including scrollbarsThere are two properties to determine the size of window:
BOM – Window MethodsMethod to open a new window with some parametersMethod Descriptionwindow.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 inputwindow.close() Closes the windowwindow.moveTo() Move the current windowwindow.resizeTo() Resize the current window
BOM – Window.open() MethodMethod & Descriptionwindow.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 – HeightReplace:• 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 MethodsThe screen object contains information about visitor’s screenProperty DescriptionavailHeight() Returns the height of the screenavailWidth() Returns the width of the screencolorDepth() Returns the bit depth of the color palette for displaying imageheight() Returns the total height of the screenwidth() Returns the total width of the screenpixelDepth() Returns the color resolution of the screen
www.webstackacademy.com ‹#›www.webstackacademy.comBOM – Navigator(BOM Browser related APIs)
BOM – Navigator ObjectThe window.navigator provides information about the browser. There is no standardimplementation for this, often most of the information is misleading. Don’t rely on it, justlearn Property DescriptionappCodeName The code name of the browserappName The name of the browserappVersion Specifies the version of the browseruserAgent Returns the user agentlanguage Returns the language of the browser.cookieEnabled Returns true if cookie is enabled otherwise falseplatform 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.comBOM – 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 Descriptionback() Loads the previous URL in the history listforward() Loads the next URL in the history listgo() Loads specific page in the history listlength Number of elements in the history list
BOM – History Objectwindow.history.forward() ; // Forwardwindow.history.back(); // Backwindow.history.go(-5); // Go back 5 timeswindow.history.go(2); // Forward two timeswindow.history.go(window.history.length-1); // Go last item
www.webstackacademy.com ‹#›www.webstackacademy.comBOM – Location(BOM User location related APIs)
BOM – Location ObjectLocation object provides general access properties of the documentProperty Descriptionwindow.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 pagewindow.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 isused, it can be configured / changed)
BOM – Location MethodsLocation object provides following methods to load / unload new documentsProperty Descriptionwindow.location.assign() Loads a new documentwindow.location.reload() Reloads the current documentwindow.location.replace() Replace the current document with a new one
www.webstackacademy.com ‹#›www.webstackacademy.comBOM – Timing Events(BOM Timer APIs)
BOM Timing EventsMethod DescriptionsetTimeout(function,duration) This function calls function after duration milliseconds fromnowsetInterval(function,duration) This function calls function after every duration millisecondsclearTimeout(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.comCookies(Storing meta information using BOM)
Cookies – What?• A Cookie is a small piece of text data set by a web server that resideson the client's machine.• The Cookie is stored on the user's computer, it does not require anyserver space .• A website can set and read only its own cookies. Primarily cookies areused for user identity management.• The document.cookie property is used while dealing withcookies
Cookies – Types & UsesCookiesSession CookiesPersistent CookiesSet 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 userlike his name, password, last visited date etc
Cookie AttributesToken Descriptionusername=value User identification informationexpires=date Set the expiration date in form of UTC (Co-ordinated Universal Time). If you don’t setcookies 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 ofthe server is usedpath=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 addedsecure Setting secure option will make the cookie to be returned only over encryptedHTTPS connection. This way it will protect other scripts accessing the cookie, whichwill enhance the security.
Setting Cookies - ExampleSyntax :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'scomputer that created the cookie.• The total number of cookies a browser can store at one time fromone particular site is limited to 20.• Each cookie is limited to about 4000 characters.
WebStack Academy#83, Farah Towers,1st Floor, MG Road,Bangalore – 560001M: +91-809555 7332E: training@webstackacademy.comWSA in Social Media:

Recommended

PDF
JavaScript - Chapter 7 - Advanced Functions
PDF
JavaScript - Chapter 3 - Introduction
PDF
JavaScript - Chapter 15 - Debugging Techniques
PDF
JavaScript - Chapter 4 - Types and Statements
PDF
JavaScript - Chapter 11 - Events
PDF
JavaScript - Chapter 8 - Objects
PDF
JavaScript - Chapter 1 - Problem Solving
PDF
JavaScript - Chapter 5 - Operators
PPTX
Static and Dynamic webpage
PPT
Introduction to Javascript
PDF
JavaScript - Chapter 6 - Basic Functions
PDF
javascript objects
PPTX
Event In JavaScript
PPTX
Lab #2: Introduction to Javascript
PDF
Regular expression in javascript
PPTX
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
PDF
JavaScript - Chapter 12 - Document Object Model
PPTX
Dynamic HTML (DHTML)
PDF
JavaScript - Chapter 10 - Strings and Arrays
PDF
Basics of JavaScript
PPT
Javascript
PPTX
Ajax ppt - 32 slides
PPTX
Css selectors
PPTX
Html images syntax
PPTX
Flexbox
PDF
Java script browser objects 1
byH K
 
PPTX
Javascript

More Related Content

PDF
JavaScript - Chapter 7 - Advanced Functions
PDF
JavaScript - Chapter 3 - Introduction
PDF
JavaScript - Chapter 15 - Debugging Techniques
PDF
JavaScript - Chapter 4 - Types and Statements
PDF
JavaScript - Chapter 11 - Events
PDF
JavaScript - Chapter 8 - Objects
PDF
JavaScript - Chapter 1 - Problem Solving
PDF
JavaScript - Chapter 5 - Operators
JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 11 - Events
JavaScript - Chapter 8 - Objects
JavaScript - Chapter 1 - Problem Solving
JavaScript - Chapter 5 - Operators

What's hot

PPTX
Static and Dynamic webpage
PPT
Introduction to Javascript
PDF
JavaScript - Chapter 6 - Basic Functions
PDF
javascript objects
PPTX
Event In JavaScript
PPTX
Lab #2: Introduction to Javascript
PDF
Regular expression in javascript
PPTX
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
PDF
JavaScript - Chapter 12 - Document Object Model
PPTX
Dynamic HTML (DHTML)
PDF
JavaScript - Chapter 10 - Strings and Arrays
PDF
Basics of JavaScript
PPT
Javascript
PPTX
Ajax ppt - 32 slides
PPTX
Css selectors
PPTX
Html images syntax
PPTX
Flexbox
Static and Dynamic webpage
Introduction to Javascript
JavaScript - Chapter 6 - Basic Functions
javascript objects
Event In JavaScript
Lab #2: Introduction to Javascript
Regular expression in javascript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
Basic Concepts of OOPs (Object Oriented Programming in Java)
JavaScript - Chapter 12 - Document Object Model
Dynamic HTML (DHTML)
JavaScript - Chapter 10 - Strings and Arrays
Basics of JavaScript
Javascript
Ajax ppt - 32 slides
Css selectors
Html images syntax
Flexbox

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

PDF
Java script browser objects 1
byH K
 
PPTX
Javascript
PPT
13488117.ppt
PPT
13488117.ppt
PPT
BOM.ppt
PPTX
Internet and Web Technology (CLASS-6) [BOM]
PPTX
12. session 12 java script objects
PDF
Html5 and beyond the next generation of mobile web applications - Touch Tou...
PPTX
Window object
PPT
Easy javascript
PPTX
19_JavaScript - Storage_Cookies-tutorial .pptx
PDF
JavaScript and BOM events
PDF
High Performance JavaScript Build Faster Web Application Interfaces 1st Editi...
PDF
Html5-Web-Storage
PPTX
HTML 5
PPT
Applied component i unit 2
PPTX
Edge of the Web
PPT
Learn javascript easy steps
PPTX
JavaScript
PPTX
Rohit&kunjan
Java script browser objects 1
byH K
 
Javascript
13488117.ppt
13488117.ppt
BOM.ppt
Internet and Web Technology (CLASS-6) [BOM]
12. session 12 java script objects
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Window object
Easy javascript
19_JavaScript - Storage_Cookies-tutorial .pptx
JavaScript and BOM events
High Performance JavaScript Build Faster Web Application Interfaces 1st Editi...
Html5-Web-Storage
HTML 5
Applied component i unit 2
Edge of the Web
Learn javascript easy steps
JavaScript
Rohit&kunjan

More from WebStackAcademy

PDF
Webstack Academy - Course Demo Webinar and Placement Journey
PDF
WSA: Scaling Web Service to Handle Millions of Requests per Second
PDF
WSA: Course Demo Webinar - Full Stack Developer Course
PDF
Career Building in AI - Technologies, Trends and Opportunities
PDF
Webstack Academy - Internship Kick Off
PDF
Building Your Online Portfolio
PDF
Front-End Developer's Career Roadmap
PDF
Angular - Chapter 9 - Authentication and Authorization
PDF
Angular - Chapter 7 - HTTP Services
PDF
Angular - Chapter 6 - Firebase Integration
PDF
Angular - Chapter 5 - Directives
PDF
Angular - Chapter 4 - Data and Event Handling
PDF
Angular - Chapter 3 - Components
PDF
Angular - Chapter 2 - TypeScript Programming
PDF
Angular - Chapter 1 - Introduction
PDF
JavaScript - Chapter 14 - Form Handling
PDF
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
PDF
jQuery - Chapter 4 - DOM Handling
PDF
jQuery - Chapter 5 - Ajax
Webstack Academy - Course Demo Webinar and Placement Journey
WSA: Scaling Web Service to Handle Millions of Requests per Second
WSA: Course Demo Webinar - Full Stack Developer Course
Career Building in AI - Technologies, Trends and Opportunities
Webstack Academy - Internship Kick Off
Building Your Online Portfolio
Front-End Developer's Career Roadmap
Angular - Chapter 9 - Authentication and Authorization
Angular - Chapter 7 - HTTP Services
Angular - Chapter 6 - Firebase Integration
Angular - Chapter 5 - Directives
Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 3 - Components
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 1 - Introduction
JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
jQuery - Chapter 4 - DOM Handling
jQuery - Chapter 5 - Ajax

Recently uploaded

PPTX
Protecting Data in an AI Driven World - Cybersecurity in 2026
PPTX
Unit-4-ARTIFICIAL NEURAL NETWORKS.pptx ANN ppt Artificial neural network
PDF
Security Technologys: Access Control, Firewall, VPN
PPTX
wob-report.pptxwob-report.pptxwob-report.pptx
PDF
API-First Architecture in Financial Systems
PDF
The major tech developments for 2026 by Pluralsight, a research and training ...
PDF
Unser Jahresrückblick – MarvelClient in 2025
PDF
Is It Possible to Have Wi-Fi Without an Internet Provider
PDF
TrustArc Webinar - Looking Ahead: The 2026 Privacy Landscape
DOCX
iRobot Post‑Mortem and Alternative Paths - Discussion Document for Boards and...
PDF
The year in review - MarvelClient in 2025
PPTX
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
PDF
Energy Storage Landscape Clean Energy Ministerial
PDF
Six Shifts For 2026 (And The Next Six Years)
PDF
Internet_of_Things_IoT_for_Next_Generation_Smart_Systems_Utilizing.pdf
PPTX
cybercrime in Information security .pptx
PDF
Day 2 - Network Security ~ 2nd Sight Lab ~ Cloud Security Class ~ 2020
PPTX
Cybercrime in the Digital Age: Risks, Impact & Protection
PDF
Eredità digitale sugli smartphone: cosa resta di noi nei dispositivi mobili
PDF
Decoding the DNA: The Digital Networks Act, the Open Internet, and IP interco...
Protecting Data in an AI Driven World - Cybersecurity in 2026
Unit-4-ARTIFICIAL NEURAL NETWORKS.pptx ANN ppt Artificial neural network
Security Technologys: Access Control, Firewall, VPN
wob-report.pptxwob-report.pptxwob-report.pptx
API-First Architecture in Financial Systems
The major tech developments for 2026 by Pluralsight, a research and training ...
Unser Jahresrückblick – MarvelClient in 2025
Is It Possible to Have Wi-Fi Without an Internet Provider
TrustArc Webinar - Looking Ahead: The 2026 Privacy Landscape
iRobot Post‑Mortem and Alternative Paths - Discussion Document for Boards and...
The year in review - MarvelClient in 2025
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
Energy Storage Landscape Clean Energy Ministerial
Six Shifts For 2026 (And The Next Six Years)
Internet_of_Things_IoT_for_Next_Generation_Smart_Systems_Utilizing.pdf
cybercrime in Information security .pptx
Day 2 - Network Security ~ 2nd Sight Lab ~ Cloud Security Class ~ 2020
Cybercrime in the Digital Age: Risks, Impact & Protection
Eredità digitale sugli smartphone: cosa resta di noi nei dispositivi mobili
Decoding the DNA: The Digital Networks Act, the Open Internet, and IP interco...

JavaScript - Chapter 13 - Browser Object Model(BOM)

  • 1.
  • 2.
  • 3.
    BOM• The BrowserObject Model (BOM) is used to interact with the browser.• These BOM provides access to the various characteristics of a browser (Browserwindow itself, Screen characteristics, Browser history etc…)• The default object of browser is window means we can call all the functions ofwindow by specifying window or directly.• If a document contain frames (<iframe> tags), the browser creates one windowobject for the HTML document, and one additional window object for each frame.Example :window.alert("Hello World");
  • 4.
    DOM and BOM- DifferencesDocument Object Model (DOM) Browser Object Model (BOM)• DOM, the document object model, whichrepresents the contents of the web page. Wecan manipulate it using JavaScript.• All the objects are arranged as tree structure.There are various APIs provided to access andmanipulate 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 pagewhich includes browser attributes (ex: Location)and the page becomes a child of Browser.• All global JavaScript objects, functions and variablesautomatically become members of the windowobject.• Using BOM, we can modify, move the window orcan change the text in status bar, read the currentURL, go back or forward of the current page
  • 5.
  • 6.
  • 7.
    BOM – WindowSize<script>var w = window.innerWidth;var h = window.innerHeightvar x = document.getElementById("ex");x.innerHTML = “Width: " + w + “<br>” + " Height: " + h;</script>Property Descriptionwindow.innerHeight The browser's client area height including scrollbarswindow.innerWidth The browser's client area width including scrollbarsThere are two properties to determine the size of window:
  • 8.
    BOM – WindowMethodsMethod to open a new window with some parametersMethod Descriptionwindow.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 inputwindow.close() Closes the windowwindow.moveTo() Move the current windowwindow.resizeTo() Resize the current window
  • 9.
    BOM – Window.open()MethodMethod & Descriptionwindow.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 – HeightReplace:• 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 – WindowScreen MethodsThe screen object contains information about visitor’s screenProperty DescriptionavailHeight() Returns the height of the screenavailWidth() Returns the width of the screencolorDepth() Returns the bit depth of the color palette for displaying imageheight() Returns the total height of the screenwidth() Returns the total width of the screenpixelDepth() Returns the color resolution of the screen
  • 11.
  • 12.
    BOM – NavigatorObjectThe window.navigator provides information about the browser. There is no standardimplementation for this, often most of the information is misleading. Don’t rely on it, justlearn Property DescriptionappCodeName The code name of the browserappName The name of the browserappVersion Specifies the version of the browseruserAgent Returns the user agentlanguage Returns the language of the browser.cookieEnabled Returns true if cookie is enabled otherwise falseplatform Browser platform (OS)
  • 13.
    BOM – NavigatorObject<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.
  • 15.
    BOM – HistoryObject• 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 Descriptionback() Loads the previous URL in the history listforward() Loads the next URL in the history listgo() Loads specific page in the history listlength Number of elements in the history list
  • 16.
    BOM – HistoryObjectwindow.history.forward() ; // Forwardwindow.history.back(); // Backwindow.history.go(-5); // Go back 5 timeswindow.history.go(2); // Forward two timeswindow.history.go(window.history.length-1); // Go last item
  • 17.
  • 18.
    BOM – LocationObjectLocation object provides general access properties of the documentProperty Descriptionwindow.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 pagewindow.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 isused, it can be configured / changed)
  • 19.
    BOM – LocationMethodsLocation object provides following methods to load / unload new documentsProperty Descriptionwindow.location.assign() Loads a new documentwindow.location.reload() Reloads the current documentwindow.location.replace() Replace the current document with a new one
  • 20.
  • 21.
    BOM Timing EventsMethodDescriptionsetTimeout(function,duration) This function calls function after duration milliseconds fromnowsetInterval(function,duration) This function calls function after every duration millisecondsclearTimeout(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.
  • 22.
  • 23.
    Cookies – What?•A Cookie is a small piece of text data set by a web server that resideson the client's machine.• The Cookie is stored on the user's computer, it does not require anyserver space .• A website can set and read only its own cookies. Primarily cookies areused for user identity management.• The document.cookie property is used while dealing withcookies
  • 24.
    Cookies – Types& UsesCookiesSession CookiesPersistent CookiesSet 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 userlike his name, password, last visited date etc
  • 25.
    Cookie AttributesToken Descriptionusername=valueUser identification informationexpires=date Set the expiration date in form of UTC (Co-ordinated Universal Time). If you don’t setcookies 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 ofthe server is usedpath=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 addedsecure Setting secure option will make the cookie to be returned only over encryptedHTTPS connection. This way it will protect other scripts accessing the cookie, whichwill enhance the security.
  • 26.
    Setting Cookies -ExampleSyntax :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• Cookiescan identify the computer being used , not the individual.• Cookies cannot access by any other computer except the visitor'scomputer that created the cookie.• The total number of cookies a browser can store at one time fromone particular site is limited to 20.• Each cookie is limited to about 4000 characters.
  • 28.
    WebStack Academy#83, FarahTowers,1st Floor, MG Road,Bangalore – 560001M: +91-809555 7332E: training@webstackacademy.comWSA in Social Media:

[8]ページ先頭

©2009-2025 Movatter.jp