Valhalla Legends Forums Archive | Web Development | Inserting one html file into another

LennyIs there any way to insert one html file into another using javascript or html?

To clarify, is it possible to append to the bottom of one html file text from another file?

Frames would seem like a very expensive way to do this, especially when there could be hundreds of them.
June 17, 2005, 12:42 pm
R.a.B.B.i.TUse php!


// this is index.php
echo "omg blah blah blah brbbbq<BR>";


this is morerandomcrap.htm

As for JS, I don't know how, but I'm sure there's a way.  As for doing it in HTML, not possible.
June 17, 2005, 06:33 pm
BlazeDo NOT use include.

require_once "Blah.html";

Thats the best of the 4 requires/includes.
June 17, 2005, 07:32 pm
Arta[vL]Why?June 17, 2005, 08:56 pm
BlazeYou could go off in a loop if a page is poorly constructed.

Example of a poorly constructed page:
= $_GET[page]

index.php?page=index.php would loop on forever.

Use require so the page will stop loading as soon as it hits the error.
June 17, 2005, 09:16 pm
AkamasI would use,
echo file_get_contents('file.html');

I would use this because PHP will parse the file if you use include() or require(). Considering that you know that there isn't any PHP in "file.html", its just best to use file_get_contents, because all its doing is reading the file and spitting out the data.
June 17, 2005, 09:17 pm
WarriorIt also allows you to construct an optional templating engine replacing tags that you define :]June 17, 2005, 09:19 pm
You could go off in a loop if a page is poorly constructed.

In other words, it hides bad design? require_once wouldn't fail on a recursive or circular include.

You'll notice a bad include pretty quickly whther you're using require or include. What does it matter?

Prior to version 4.0.something, require is not affected by conditional statements. In other words, this require would always execute:

   require 'x.php';

Thus, I contend that require is bad; include is much more reliable and no less error prone, assuming you have warnings enabled on your development box.
June 17, 2005, 09:29 pm
Warriorsometimes you have code that can't be declared more than once (classes) and you may have a file that accidently includes it once (and to save you the trouble of worrying about it) include_once makes sure not to re-include if it already has been.June 17, 2005, 09:32 pm
Arta[vL]Accidentally being the key word. Languages shouldn't help programmers desguise bad design choices. require_once and include_once are both things that lull one into a false sense of security - rather like "on error resume next".

Require is fine for most things, but problem-prone on servers running old versions of php. Include is safer, and is thus a better choice.
June 17, 2005, 09:43 pm
LennyWell as far as using javascript goes...

Is it possible to do anything similar to a countdown, where a number is displayed after 1 second has passed?


I'm having issues where window.setTimeout() and window.setInterval() only fire once with document.write()'s...
June 17, 2005, 10:02 pm