Open In App

How to change the title of a framed document ?

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:

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”.




<!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>




<!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>




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




<!DOCTYPE html>
<html>
  
<body bgcolor="cyan">
  <h1>
    Welcome to GeeksforGeeks
  </h1>
  
  <img src=
</body>
  
</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:


Article Tags :