attach html code?

liunx

Guest
I was wondering if there was a way to include html from another file, so you could make one header file and have multiple pages reference that one header file.<!--content-->In a couple of ways. Make the header as its own file.<br />
<br />
Your other pages can include it by way of...<br />
<br />
1) An Iframe <br />
<Iframe src=http://www.htmlforums.com/archive/index.php/header.html width=set width height=set height scrolling=no></iframe><br />
2) As a virtual include, if the pages have an .shtml extension.<br />
<!--#include virtual="header.html"--><!--content-->Find out from your ISP if you can use server-side includes (SSI), or you can use server-side languages such as PHP or ASP.<br />
<br />
Those facilities are what you really need.<!--content-->Originally posted by giz <br />
Find out from your ISP if you can use server-side includes (SSI), or you can use server-side languages such as PHP or ASP.<br />
<br />
Those facilities are what you really need. <br />
<br />
Yeah, I have php and was thinking about using include(). With this, can I include html directly or do I need to parse it via php somehow?<br />
<br />
Also, would there be a way that is similar to how you can link a page to a javascript file or possibly include html through a javascript function?<!--content-->You put the piece of HTML, the one that you want to include, inside an include file, with whatever filename you want.<br />
<br />
You then call that file from the main HTML file, at the point that you want the other HTML code to appear.<br />
<br />
<br />
<br />
littlefile.php:<br />
<br />
<td> this code is included </td><br />
<br />
<br />
<br />
mainfile.php:<br />
<br />
<html><br />
<head>..</head><br />
<body><br />
<table><br />
<tr><br />
<td> this code is in the main file</td><br />
<?PHP include("littlefile.php"); ?><br />
</tr><br />
</table><br />
</body><br />
</html><br />
<br />
<br />
<br />
<br />
Upload both of those files, and view the page on your browser, then do a view source. It will look like one page of HTML. You will not be able to see the join, or have any hint that some code was included from another file by the server.<br />
<br />
<br />
<br />
If you want to play with PHP offline, then get a copy of PHPdev (Google for it). This free package includes the Apache web server, and PHP, a mySQL database, the Cerebus FTP server, an example website, an example invision forum, and a few other things.<!--content-->That helps out a lot, thank you.<!--content-->>> Also, would there be a way that is similar to how you can link a page to a javascript file or possibly include html through a javascript function? <<<br />
<br />
You can, but it is messy. It slows down the browser. It doesn't work in all browsers. It doesn't work if the user turned javascript off. If the code includes some links to other pages then the search engines cannot follow those links.<br />
<br />
Server side code, like PHP, is much better. The "joins" are invisible to the end user.<!--content-->
 
Back
Top