HTML Element: <iframe>
[this page | pdf | back links]
The HTML <iframe> element indicates an
inline frame. It can also be used to embed another document within the current
HTML document.
The attributes it can take
(other than HTML
global attributes and HTML event attributes)
include:
Attribute
|
Description
|
More
|
height
|
Height of element
|
Here
|
name
|
Name of element
|
Here
|
sandbox
|
Allows an extra set of
restrictions for the content of an <iframe>
element
|
Here
|
src
|
URL of
resource
|
Here
|
srcdoc
|
HTML content of page to
show in an <iframe>
|
Here
|
width
|
Width of element
|
Here
|
It used to support the align, frameborder,
longdesc, marginheight, marginwidth and scrolling
attributes, but these are no longer supported by HTML 5.
To
create or access such an element in JavaScript
see here. The
corresponding HTML DOM
object supports standard
DOM properties and methods, and additional properties with the same name and
meaning as the attributes of the underlying HTML element referred to above. It
also supports the following additional properties:
Property
|
Description
|
More
|
contentDocument
|
Returns document object
generated by the iframe
|
Here
|
contentWindow
|
Returns window object
generated by the iframe
|
Here
|
The default style
applicable to this element is shown here.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<iframe src="http://www.nematrian.com"></iframe>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("IFRAME");
x.setAttribute("src","http://www.nematrian.com");
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements