The Wayback Machine - https://web.archive.org/web/20241117095938/https://www.geeksforgeeks.org/how-to-place-a-div-inside-an-iframe-for-ie/
Open In App

How to place a div inside an iframe for IE ?

Last Updated : 17 Jun, 2020
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Introduction: An Iframe is used to display a web page (or possibly a document) within a web page, i.e. it loads the contents of a page (or document) inside the current page.

Iframe Syntax:

<iframe src="URL"></iframe>

Approach 1: For adding additional div’s in an iframe, you need to use a wrapper div, that wraps the contents of your intended div and the iframe into one unit. This way you can display the contents of your div along with the iframe embedding to the document/webpage.

Example:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to place a div inside
        an iframe for IE?
    </title>
</head>
  
<body>
    <h2>Div in an Iframe</h2>
  
    <div id="container" style="border: solid 2px #000;">
        <iframe height="500px" 
            width="100%" name="iframe_a">
        </iframe>
  
        <div>
            <h2>This goes in the iframe</h2>
            <h1> This is another heading </h1>
        </div>
          
        <!-- Put all your contents 
            of the div here -->
    </div>
  
    <p><a href="https://ide.geeksforgeeks.org/" 
            target="iframe_a">
            Click Here
        </a>
    </p>
</body>
  
</html>                    


Output:

Explanation: The div with id = “container” is the wrapper/container for the iframe and the contents of the div, thus the contents of the div are displayed along with the iframe.

Approach 2: Another way of handling the problem is to use the iframe itself for displaying the contents of the div instead of displaying them along with the iframe. However, this way the iframe only displays either the contents of the div or of the webpage/document at any point of time, thus this approach is a bit limited.

Syntax:

<iframe srcdoc="div goes here"></iframe>

Example:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to place a div inside
        an iframe for IE?
    </title>
</head>
  
<body>
    <h2>Div in an Iframe</h2>
    <div id="container" style=
            "border: solid 2px #000;">
        <iframe srcdoc="<div>
            <h2>This goes in the iframe</h2>
             </div>" height="500px" 
             width="100%" name="iframe_a">
        </iframe>
        <!-- Put all your contents 
            of the div here -->
    </div>
  
    <p><a href="https://ide.geeksforgeeks.org/"
            target="iframe_a">
            Click Here
        </a>
    </p>
</body>
  
</html>


Output:

Explanation: In the above example, the iframe displays the div containing the text: “This goes in the iframe”, and whenever the “Click Here” link is clicked the iframe loads the target URL page in the iframe, overwriting the div that was present earlier. Doing this would load the Wikipedia page, however, to display the contents of the div again you would require to reload the page.



Previous Article
Next Article

Similar Reads

How to Place Border Inside Div and Not on its Edge in CSS ?
CSS(Cascading Style Sheet) is a language that provides a style and describes the presentation of a website written in HTML. It provides different layouts, and the appearance of a page, including text, images, and other animation controls. It separates the content and structure of a web page from its presentation, allowing designers to change the ap
3 min read
How to clear all div's content inside a parent div ?
In this article, we are given an HTML document containing div elements and the task is to remove the existing HTML elements using jQuery. To accomplish this task, we can use the following methods: Table of Content jQuery remove() methodjQuery empty() methodjQuery html() methodjQuery remove() methodThe remove() method in jQuery is used to remove the
2 min read
How to check if an iframe is present in another iframe in JavaScript ?
In this article, we will see how to check if an iframe is present in another iframe, along with understanding its basic implementation with the help of a simple example. An iFrame is an HTML element that allows users to embed a webpage within another webpage. It's frequently used for displaying content from another website, such as a video or a soc
4 min read
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 inli
2 min read
How to check a webpage is loaded inside an iframe or into the browser window using JavaScript?
An iFrame is a rectangular frame or region in the webpage to load or display another separate webpage or document inside it. So basically, an iFrame is used to display a webpage within a webpage. You can see more about iFrames here : HTML iFrames There may be a variety of reasons for checking whether a webpage is loaded in an iFrame, for example, i
4 min read
How to Adjust the Width and Height of an iframe to Fit the Content Inside It?
When using the <iframe> tag in HTML, the content inside the iframe is displayed with a default size if the width and height attributes are not specified. Even if the dimensions are specified, it can still be difficult to perfectly match the iframe’s size with the content inside it. This can be especially challenging when the content inside th
4 min read
How to place two div side-by-side of the same height using CSS?
The two or more different div of same height can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. The used display property are listed below: display:table; This property is used for elements (div) which behaves like table.display:table-cell; This proper
2 min read
How to place SVG icons on a round circle side by side to another div using Bootstrap?
Bootstrap Icons are SVGs, so they scale quickly and easily and can be styled with CSS. Approach: We can place the SVG icons and give them the shape of a circle. This will make the SVG icons appear to be in a circular shape. This can be achieved using a Bootstrap class called "rounded-circle" Syntax: <img class = "rounded-circle" src = "..." alt
2 min read
How to place image or video inside Silhouette ?
In this article, we will learn how to place an image or video inside a silhouette using CSS. Before that, let's have a brief definition of a silhouette. It is basically an image of any person, animal or it could be any object which is represented by a solid palette of color. In general, it is in black color. Basically, what we are going to do in th
2 min read
How to force child div to be 100% of parent div's height without specifying parent's height?
When designing a website, you may want to create a layout where a child div element fills up the height of its parent div element. However, you may not know the exact height of the parent div element and you don't want to specify it. In this article, we will explore different approaches to force a child div element to be 100% of its parent div elem
3 min read
How to copy the content of a div into another div using jQuery ?
Given an HTML document containing some div element and the task is to copy a div content into another div as its child using jQuery. There are two approaches to solve this problem that are discussed below: Approach 1: First, select the div element which needs to be copied into another div element.Select the target element where the div element is c
2 min read
How to center a div on the edge of another div in SASS ?
In this article, we will see how to centre a div on the edge of another div using SASS. SASS is an extension of CSS that stands for Syntactically Awesome Style Sheets. It helps us to create things like variables, nested rules, etc. So that we can reuse the code. Centering a div on the edge of another div is not a difficult task. We can achieve it b
4 min read
How to Make a Child Div Element Wider than Parent Div using CSS ?
When the child div element has a fixed width that is wider than the parent div element, it will display overflow outside of the parent element. Because the overflow is hidden by default, one approach is to utilize the overflow attribute to enable it on an element. Another approach includes setting the position property of the parent div element to
2 min read
How to make Parent Div Activate Styling of Child Div for Hover and Active ?
In this article, we will see how to make parent div activate styling of child div for hover and active. We can do this by using Pseudo-classes like hover and active. Approaches to make parent div activate styling of child div for hover and activeUsing Pure CSS: with pseudo-classesUsing CSS and JavaScript: without pseudo-classesMethod 1: Using Pure
2 min read
How to overlay one div over another div using CSS
Creating an overlay effect simply means putting two div together at the same place but both the div appear when needed i.e while hovering or while clicking on one of the div to make the second one appear. Overlays are very clean and give the webpage a tidy look. It looks sophisticated and is simple to design. Overlays can create using two simple CS
2 min read
How to make div fixed after scroll to that div ?
In this article, we will see how to make a div fixed after you scroll to it by using the position property with a sticky value. This effect is generally used on websites when an important message needs to be shown. Set the property position to sticky to create elements that behave as fixed positions whenever the user scrolls to that position. Fixin
4 min read
How to Overlay/Hover Div in Flexbox Container Div?
In CSS, overlay/hover effects can be achieved by using Flexbox containers to center content and applying styles to reveal overlays on hover. By positioning elements absolutely within a Flexbox container, overlays can cover the entire content area. These are the following approaches: Table of Content Using ::before Pseudo-elementUsing an Overlay Div
3 min read
How to Center a Div within another Div?
We are given a HTML div inside another div tag and the task is to center the inside div. The div tag is used to construct a division or section of an HTML document in which other elements of HTML is placed. Syntax:<div> <h3>'This is a div of the web page.>/h3> <p>This is some text in a div element.</p></div> Exam
4 min read
How to get elements of specific class inside a div ?
In this article, we will find how to get all elements of a specific class inside an HTML div tag. To do this we will use HTML DOM querySelectorAll()method. This method of HTML DOM (document object model) returns all elements in the document that matches a specified CSS selector(s). The syntax to use this method is as follows. Syntax: document.query
1 min read
Image inside div has extra space below the image in CSS
Sometimes when you insert an image inside a div element, you might notice that there is extra space below the image. This can happen due to various reasons such as the image having a different aspect ratio than the div, or the div having padding or margin that affects the image placement. In this article, we will discuss different approaches to sol
5 min read
How to make an image center-aligned (vertically & horizontally) inside a bigger div using CSS ?
We will know how to center-align the image in a div tag using CSS & will also understand its implementation through the example. Given an image, we need to set the image that align to the center (vertically and horizontally) inside a bigger div. But first let's create a basic structure, in which inside the body tag with id=outer there is an img
2 min read
How to use the $index inside a ng-repeat to enable a class and show a DIV in AngularJS ?
In AngularJS applications, we can use the $index variable within an ng-repeat directive to enable a class and show a DIV element based on the index of the current item in the iteration. The $index variable represents the current index of the item being processed in the ng-repeat loop. Similarly, to show or hide a DIV element, you can use the ng-sho
6 min read
How to move one DIV element inside another using jQuery ?
In this article, we will learn to move one HTML div element inside another using jQuery. The HTML div element is used to define a division or a section in an HTML document. Method used: parent(): This method is used to get the parent of each element in the current set of matched elements, optionally filtered by a selector.detach(): This method is u
2 min read
How to Scroll to an Element Inside a Div using JavaScript?
To scroll to an element within a div using JavaScript, set the parent div's scrollTop`to the target element's offsetTop. This method allows smooth navigation within a scrollable container. Below are the methods to scroll to an element inside a Div using JavaScript: Table of Content Using scrollIntoView( ) method Using scroll( ) method Using scrollT
3 min read
How to Vertically Align an Image Inside a Div in CSS ?
In this article, we are going to see how we can vertically align an image inside a div. Centering content both vertically and horizontally is one of the most important functions which needs to be done. Below are the approaches to vertically align an image inside a div in CSS:   Table of Content Using CSS Display propertyUsing CSS Position Propertie
4 min read
HTML | <iframe> width Attribute
The HTML <iframe> width attribute is used to specify the width of the <iframe> in terms of pixels. Syntax: <iframe width="pixels"> Attribute Values: It contains single value pixel which specifies the width of the iframes in terms of pixels. Below example illustrates the use of <iframe> width attribute in HTML: Example: C/C++
1 min read
HTML | DOM IFrame Object
The IFrame Object property in HTML DOM is used to create and access the <iframe> element within the object. An inline frame is used for embedding another document within the current HTML document. Syntax: It is used to access a <iframe> element.var x = document.getElementById("myframe");It is used to create a <iframe> element.var
3 min read
HTML | <iframe> height Attribute
The HTML <iframe> height attribute is used to specify the height of the <iframe> in terms of pixels. Syntax: <iframe height="pixels"> Attribute Values: It contains single value pixel which specifies the height of the iframes in terms of pixels. Below example illustrates the use of <iframe> height attribute in HTML: Example:
1 min read
HTML | <iframe> src Attribute
The HTML <iframe> src attribute is used to specify the URL of the document that are embedded to the <iframe> element. Syntax: <iframe src="URL"> Attribute Values: It contains single value URL which specifies the URL of the document that is embedded to the iframe. There are two types of URL link which are listed below: Absolute URL
1 min read
HTML | <iframe> name Attribute
The HTML iframe name Attribute is used to specify a reference for an <Iframe> Element. The name attribute is also used as a reference to the elements in a Javascript. Syntax: <iframe name="name"> Attribute Values: name: It specify the name for the Iframe element. Example: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt;
1 min read
three90RightbarBannerImg