How to include an HTML page into another HTML page without frame/iframe?
I want to include an HTML page inside an HTML page. Is it possible?
I don't want to do it in PHP, I know that in PHP, we can use include
for this situation, how can I achieve the same purely in HTML without using the iframe
and frame
concept?
Solution 1:
You can use an object element
<object type="text/html" data="urltofile.html"></object>
or, on your local server, AJAX can return a string of HTML (responseText) that you can use to document.write a new window, or edit out the head and body tags and add the rest to a div or another block element in the current page.
Solution 2:
If you're just trying to stick in your own HTML from another file, and you consider a Server Side Include to be "pure HTML" (because it kind of looks like an HTML comment and isn't using something "dirty" like PHP):
<!--#include virtual="/footer.html" -->
Solution 3:
If you mean client side then you will have to use JavaScript or frames.
Simple way to start, try jQuery
$("#links").load("/Main_Page #jq-p-Getting-Started li");
More at jQuery Docs
If you want to use IFrames then start with Wikipedia on IFrames
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example</title>
</head>
<body>
The material below comes from the website http://example.com/
<iframe src="http://example.com/" height="200">
Alternative text for browsers that do not understand IFrames.
</iframe>
</body>
</html>