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?
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?
You can say that it is with PHP, but actually it has just one PHP command, all other files are just *.html.
AddType application/x-httpd-php .html
<?php include("meniu.html"); ?>
.That's all!
Remark: all commands like
<? ...>
will be treated as php executables, so if your html have question marks, then you could have some problems.Also make sure to check out how to use Angular includes (using AngularJS). It's pretty straight forward…
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):
If you are using NGINX over linux and want a pure bash/html, you can add a mask on your template and pipe the requests to use the sed command to do a replace by using a regullar expression.
Anyway I would rather have a bash script that takes from a templates folder and generate the final HTML.
If you mean client side then you will have to use JavaScript or frames.
Simple way to start, try jQuery
More at jQuery Docs
If you want to use IFrames then start with Wikipedia on IFrames
If you're willing to use jquery, there is a handy jquery plugin called "inc".
I use it often for website prototyping, where I just want to present the client with static HTML with no backend layer that can be quickly created/edited/improved/re-presented
http://johannburkard.de/blog/programming/javascript/inc-a-super-tiny-client-side-include-javascript-jquery-plugin.html
For example, things like the menu and footer need to be shown on every page, but you dont want to end up with a copy-and-paste-athon
You can include a page fragment as follows