Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between window.title and document.title

Tags:

javascript

I am have been reading material on JavaScript and there are two ways of accessing the title of the page:

  1. The window.title property
  2. The document.title property

But when applying, the second only works. I am unable to understand why there are two titles and why both of them don't work.

like image 307
M. Ahmad Zafar Avatar asked Jun 19 '13 01:06

M. Ahmad Zafar


People also ask

What is the difference between window and document?

The window is the actual global object. The screen is the screen, it contains properties about the user's display. The document is where the DOM is.

What is a window title?

The window title for a page (often called the "title tag") is, most simply, the text that appears at the top of a visitor's web browser when viewing that page.

What is a document title?

Related Content. Any written instrument, such as a bill of sale, title deed, bill of lading, that proves ownership or control and possession. A person in possession of a document of title can receive, hold, sell or otherwise dispose of the document and the goods it covers. Resource ID 9-570-7606.

What is document title JS?

Code used to describe document style. JavaScript. General-purpose scripting language. Protocol for transmitting web resources.


1 Answers

window.document.title is correct.

window.title is incorrect, because the window object doesn't have a title property (all the properties of window are down the left side, you'll see title isn't there).

like image 91
dennythecoder Avatar answered Sep 23 '22 20:09

dennythecoder