Topic 2.4 Frameset and Iframe
Topic 2.4 Frameset and Iframe
2
FRAME AND FRAMESET
• Frameset used to split the visual real estate of a browser window into multiple
frames.
• Each frame has it’s own contents and the content in one don’t spill into the next.
Frameset
3
FRAME AND FRAMESET
4
FRAME AND FRAMESET
Usability challenges:
Accessibility challenges:
• Screen readers and other assistive technologies have a very hard time
understanding and communicating websites that use frames.
5
FRAME AND FRAMESET
6
FRAME AND FRAMESET
Example:
7
FRAME AND FRAMESET
Example:
8
FRAME AND FRAMESET
Example:
9
Activity 2.10 : Frame and Frameset
10
Activity 2.11 : Frame and Frameset
11
FRAME AND FRAMESET
noresize
scrolling
13
FRAME AND FRAMESET
Embedded HTML frames
<frameset rows="15%,*,10%">
<frame src="header.html" name="top" id="top" />
<frameset cols="20%,*,11%">
<frame src="menu.html" name="left" id="left" />
<frame src="home.html" name="home" id="home" />
<frame src="right.html" name="right" id="right" />
</frameset>
<frame src="footer.html" name="bottom" id="bottom" />
<noframes>
<body> <p><a href="menu.html">Contents</a></p>
</body>
</noframes>
</frameset>
14
FRAME AND FRAMESET
Embedded HTML frames
top
<frameset rows="15%,*,10%">
<frame src="header.html" name="top" id="top" />
<frameset cols="20%,*,11%">
<frame src="menu.html" name="left" id="left" />
<frame src="home.html" name="home" id="home" />
<frame src="right.html" name="right" id="right" />
</frameset> left home right
<frame src="footer.html" name="bottom" id="bottom" />
<noframes>
<body> <p><a href="menu.html">Contents</a></p>
</body>
</noframes>
</frameset>
bottom
15
FRAME AND FRAMESET
16
iFRAME
An iframe (short for inline frame) is and HTML element that allows you to
embed a web page or other content within your web page
17
iFRAME
• Or you can add the style attribute and use the CSS height and width properties
Example:
<iframe src="demo_iframe.htm" style="height:200px;width:300px;" title="Iframe Example"></iframe>
18
iFRAME
Example:
<iframe src="demo_iframe.htm" style="border:none;" title="Iframe Example"></iframe>
• With CSS, you can also change the size, style and color of the iframe's border
Example:
<iframe src="demo_iframe.htm" style="border:2px solid red;" title="Iframe Example"></iframe>
19
iFRAME
Example:
<iframe src="demo_iframe.htm" name="iframe_a" title="Iframe Example"></iframe>
20
iFRAME
Other attributes
• You can also add other attributes to the iframe element, such as name, id, class, style,
and sandbox, depending on your needs.
Example:
<iframe src="https://www.example.com" width="500" height="500" name="example-iframe"
id="example-iframe" class="iframe-class" style="border: none;" sandbox="allowscripts">
</iframe>
In this example, the name and id attributes give the iframe a unique identifier, the class attribute applies a CSS class to
the iframe, the style attribute sets a custom border style, and the sandbox attribute restricts what the embedded page
can do (in this case, allowing only scripts to be executed)
21
iFRAME PROPERTIES
Here are some of the common properties and attributes of an iframe in HTML:
• src: Specifies the URL of the web page to be embedded in the iframe.
• width and height: Specifies the dimensions of the iframe in pixels.
• name and id: Specifies a unique identifier for the iframe.
• class and style: Specifies a CSS class and inline styles for the iframe.
• Frameborder and allowfullscreen: Specifies whether the iframe should have a border and whether it
should be allowed to enter full-screen mode.
• scrolling: Specifies whether scrollbars should appear within the iframe if the content is larger than the
dimensions of the iframe.
• sandbox: Specifies a set of restrictions on the embedded page, such as preventing scripts or plugins from
running.
• seamless: Specifies that the iframe should appear to be part of the parent document, without any borders
or padding.
• srcdoc: Specifies the HTML content of the iframe directly, instead of loading it from a separate URL.
These properties and attributes can be used to customize the appearance and behavior of the iframe and its
embedded content.
22
Techniques of iFrame design
There are several techniques for designing iframes in HTML. Here are a few common ones:
• Basic iframe: This technique involves creating a simple iframe that displays a web page inside the parent web page. It can be
customized with the src, width, height, and other attributes to fit the desired layout.
• Responsive iframe: This technique involves using CSS to make the iframe responsive to the size of the screen or viewport, so
that it scales and resizes automatically. This can be achieved by setting the width and height to a percentage value and using
CSS media queries to adjust the iframe's size and layout for different screen sizes.
• Floating iframe: This technique involves using CSS to make the iframe float or hover over the parent web page, creating a
dynamic effect. This can be achieved by using the position and z-index CSS properties to control the positioning and layering of
the iframe.
• Cross-domain iframe: This technique involves using an iframe to display content from a different domain or server than the
parent web page. This can be useful for embedding third-party content, such as videos, maps, or social media widgets.
However, cross-domain iframes can raise security concerns, so it's important to use them carefully and avoid exposing
sensitive data or functionality.
These are just a few examples of the many techniques that can be used to design iframes in HTML. The choice of technique will
depend on the specific requirements of the web page and the desired user experience.
23
Techniques of iFrame design
Here are some examples of how to use different techniques to create iframes in HTML:
Basic iframe: This technique involves creating a simple iframe that displays a web page inside the parent web page. It
can be customized with the src, width, height, and other attributes to fit the desired layout
Example:
Example:
These examples illustrate some of the different techniques that can be used to create iframes in HTML,
including basic iframes, responsive iframes, floating iframes, and cross-domain iframes. By adjusting the
attributes and styles of the iframe element, you can customize the appearance and behavior of the iframe
to fit your needs.
26
Activity 2.12 : iFrame
27
Activity 2.13 : iFrame
28