Skip to content
Related Articles

Related Articles

How to change the title of a framed document ?

Improve Article
Save Article
  • Last Updated : 10 Mar, 2022
Improve Article
Save Article

In this article, we will learn about the way to change the Title of a Framed Document.

HTML Frames and Frameset: The use of Frames is to divide the window of a browser into multiple sections in which each section is loaded separately. These are used to specify which HTML document will be loaded in the particular frame. The <frameset> tag is used instead of the <body> tag in order to specify the way for dividing the browser window. It uses rows and cols attribute for specifying the area to be occupied by frames. 

Note: The <frame> tag and <frameset> tag are not supported by HTML5. 

Changing the Title of a Framed Document: The title shown is the title of the frameset document rather than the titles of any of the specified pages within frames. We need to link to a new frameset document in order to change the title displayed using the TARGET attribute. When we specify target=”_top”, it replaces the entire frameset.

Syntax of target attribute :

<a target="_top || _self || _blank || _parent"> 
    ...
</a>

Here, the Linked Text will act as a hyperlink that will be open in the web browser when clicked by visitors depending upon the value of the target attribute.

Values of a target attribute: This attribute refers to the target window for the URL mentioned with href attribute. Following are its possible values:

  • _top: It loads the webpage into a browser window using full-body i.e. by replacing existing frames.
  • _self: By default, _self is the value for the target attribute. It loads the webpage in the same window/frame from which the link is clicked.
  • _blank: It loads the webpage in a new window of the browser.
  • _parent: It loads the webpage in the parent window/frameset.
  • framename: If you want to load the contents of the webpage into another frame then the NAME attribute is to be specified within <FRAME> element of HTML in which the contents of the linked page will be displayed. Also, there is a need to specify the target attribute of <a> element and the name of the frame in which contents will be shown.

Let’s understand with an example about the way to change the title of a framed document using TARGET attribute when its value is set to “_top”.

  • Create an HTML document target_top.html for dividing the webpage into multiple sections.

target_top.html




<!DOCTYPE html>
<html>
  
<frameset cols="20%,*">
  <frame src="target_topframe.html">
    <frame name="f3" src="targettop.html">
</frameset>
  
<noframes>
  <body>
    Your browser does not support frames.
  </body>
</noframes>
  
</html>


  • Create an HTML document target_topframe.html that illustrates the usage of the TARGET attribute.

target_topframe.html




<!DOCTYPE html>
<html>
  
<body>
  <a href="target_top.html" 
     target="_blank">
    TARGET_BLANK 
  </a><br><br>
  
  <a href="welcome.html" 
     target="_top">
    TARGET_TOP 
  </a><br><br>
  
  <a href="welcome1.html" 
     target="f3">
    TARGET_FRAMENAME 
  </a><br><br>
</body>
  
</html>


  • Create a HTML document targettop.html

targettop.html




<!DOCTYPE html>
<html>
  
<body bgcolor="black">
  <img src=
</body>
  
</html>


  • Create a HTML document welcome.html

welcome.html




<!DOCTYPE html>
<html>
  
<body bgcolor="cyan">
  <h1>
    Welcome to GeeksforGeeks
  </h1>
  
  <img src=
</body>
  
</html>


  • Create a HTML document welcome1.html

welcome1.html




<!DOCTYPE html>
<html>
  
<body bgcolor="cherry">
  <h1>
    Welcome to GeeksforGeeks
  </h1>
  
  <img src=
</body>
  
</html>


Firstly, an HTML document is created for dividing the webpage into 2 sections using the frameset cols attribute. Then target_topframe.html document is created for specifying the links that can be clicked in order to see the effect of the TARGET document. The targettop.html, welcome.html, and welcome1.html are created for displaying contents. It can be clearly seen that when TARGET=”_top” is set then the title of the frameset document gets changed.

Output:


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!