Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include an HTML page into another HTML page without frame/iframe?

Tags:

html

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?

like image 723
praveenjayapal Avatar asked Mar 24 '09 07:03

praveenjayapal


People also ask

How do I embed a page without an iframe?

Use the object Tag as an Alternative to Iframe in HTML The object tag is an alternative to the iframe tag in HTML. We can use the tag to embed different multimedia components like image, video, audio, etc. The object tag has an attribute data where we can define the URL of the webpage to be embedded.

Can we have HTML inside HTML?

You just have to include it again wherever you use the <div data-include="/path/to/include. html"></div> .

How do I display another HTML page in a div?

To load external HTML into a <div>, wrap your code inside the load() function. To load a page in div in jQuery, use the load() method.


1 Answers

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.

like image 91
kennebec Avatar answered Oct 03 '22 16:10

kennebec