Browser - Document variable (DOM) - Javascript

Browser

About

In a browser, the document is:

The document is provided by the browser via its DOM webapi (Not by the Javascript engine, DOM is not a standard javascript library)

Variable

The document variable exists as a global variable

The document variable is:

  • is a property of the window object
  • accessible globally through an alias

Example

type = document.contentType;
console.log("The document type is "+type);

Browser Detection

The presence of the document object tells you that Javascript is running in:

  • a browser
  • or a library that supports DOM such as JsDom
if (typeof document !== 'undefined') {
  // We are in a browser context
} else {
  // We are in a non-browser context (node without dom library)
}





Discover More
Global Namespace Web Console Firefox
Browser - (Window | Tab) (Javascript Global scope)

window: is a javascript object that represents a tab in the whole browser that render a document. is the javascript global scope for the variable in the browser. is part of the web api holds the...
DOM - Document (Object)

Every XML doc and HTML document (Web page) in an HTML UA is represented by a TR/html5/dom.htmlDocument object. A document in the context of a browser is generally a HTML document (Web Page). The Document...
HTML - Document

An HTML document is a well-formed HTML string (ie that contains the html root element). web page The HTML textual representation can be stored: in a string in a file or in the body of an HTTP...
Domtree
How is the DOM document build from an HTML document ?

This page is the construction of the DOM document from a HTML document (ie the XML language is xhtml) HTMLAPIHTML The HTML dom document is created: by an xml library or by the browser at page...
Cookie Devtool
How to manage Cookies in the Browser via Javascript?

This article is HTTP cookies management in the client side (browser) via javascript. Cookie are one way to store data in the browser. document.cookie is a property of the browser document that returns...
Browser
How to use MutationObserver to track mutation on the DOM ?

An article about how to observe changes to the DOM and react to them via the MutationObserver framework
Javascript - (Interpreter|Engine|Runtime)

Javascript Interpreter (JavaScript_engineJavaScript engine) is a software which interprets and executes JavaScript code. Javascript can run in two different environment: within a browser or without...
Javascript - Browser (Web API )

API The browser in Javascript. The browser implements extra javascript object to be able to interact with it, such as: The window object of represents a window containing a DOM document; the document...
Javascript - Test

Testing with Javascript. Testing in Javascript is really dependent on which type of engine you test will be running. ie: with the DOM (in a browser against a web page) or without the DOM (ie in node)...
The referer identifies the URL of the page where the request originated.

This page shows you how to set and retrieve the referrer and points you to the specification for more details



Share this page:
Follow us:
Task Runner