Use JavaScript document.title to get the website title

 The website title ( HTML title ) is the text (also can be a symbol) used to identify the webpage at the top of the browser. HTML title can be said to be the name of the webpage. When a webpage is opened, the browser will create a DOM object model of the title. This title can be obtained through JavaScript document.title. The basic syntax structure is as follows.


document.title


JavaScript document.title implementation example
<html>
<head>
<title>This is my test page</title>
</head>
<body>
The title of the page is: <script>document.write(document.title);</script>
</body >
</html>
Rendering results: The title of the webpage is: This is my test webpage

example. It is a simple HTML webpage structure. The text in the <title></title> tag is the name of the webpage, which is obtained through the document.title of JavaScript and displayed on the webpage. The title of this paragraph is displayed on the page , and document.write means displaying a string on the web page. Extended reading JavaScript Document JavaScript document.write() method How to use HTML title tag to write the first HTML page example

Post a Comment

0 Comments