How to load a hyperlink from one iframe to another iframe ?
HTML Iframe or inline frame allows embedment of multiple HTML pages in an HTML page. In this article, we will see how to change the content of one iframe using hyperlinks in another iframe.
This can be achieved by the proper usage of the name attribute in the iframe tag and the target attribute in the anchor tag. The name attribute allows each inline frame to have its own unique name while the target attribute tells the hyperlinks, where the page has to be opened when the link is clicked. Our problem will be solved if we keep the value of the target as the name of the destination iframe where the hyperlink contents should be displayed.
- We will create an HTML page consisting of two iframes.
- Give each iframe a unique name.
- Create another HTML page with multiple hyperlinks in it.
- Add the name of the second iframe in the target attribute of every hyperlink.
- Click the links in the first iframe, and you should see the pages opening in the second iframe.
Example: The HTML document will embed two iframes inside it.
The following code is the content for “iframe1.html” used in the above code.
Output: This page will contain hyperlinks, each targeting the second iframe.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.