views:

695

answers:

5

Hi friends,

I want to include an html page inside an html page. Is it possible? Please give me the code. I dont 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?

+7  A: 
<iframe src="page.html"></iframe>

You will need to add some styling to this iframe. You can specify width, height, and if you want it to look like a part of the original page include fameborder="0".

There is no other way to do it in pure HTML. This is what they were built for, it's like saying I want to fry an egg without an egg.

Sam152
+7  A: 

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" -->
Daniel LeCheminant
This isnt a pure HTML solution is it?
Sam152
@Sam152: Shhh! ;-]
Daniel LeCheminant
Yeah +1. Its probably the better way of doing it. He also says that he doesn't want to use an iframe, so who knows which solution will work best.
Sam152
Hey, here i got a idea, i have included the whole content inside the javascript - document.write. then place the javascript file inside the html. It working
praveenjayapal
+11  A: 

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"&gt;
<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>
Cherian
Hey, here i got a idea, i have included the whole content inside the javascript - document.write. then place the javascript file inside the html. It working
praveenjayapal
A: 

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 other block element in the current page.

kennebec
A: 

@PraveenJayapal :: How to include the HTML content in a JAVASCRIPT file?? And how to place it inside the HTML page?

idleMind