• Welcome to Valhalla Legends Archive.
 

Inserting one html file into another

Started by Lenny, June 17, 2005, 12:42 PM

Previous topic - Next topic

Lenny

Is 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.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

R.a.B.B.i.T

Use php!

<?php    // this is index.php    echo "omg blah blah blah brbbbq<BR>";    include('morerandomcrap.htm');?>


<!--
this is morerandomcrap.htm
//-->
<h1>OMGROFLWAFFLE!!!</h1>


As for JS, I don't know how, but I'm sure there's a way.  As for doing it in HTML, not possible.

Blaze

Do NOT use include.


<?phprequire_once "Blah.html";?>


Thats the best of the 4 requires/includes.
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

Arta


Blaze

You could go off in a loop if a page is poorly constructed.

Example of a poorly constructed page:

<?php     $bob = $_GET[page]     include "../".$bob?>



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

Use require so the page will stop loading as soon as it hits the error.
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

Akamas

#5
I 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.
Quote from: Arta[vL] on August 14, 2006, 04:57 PM
Well, I want some too. Greedy Yoni should stop hogging it.

Warrior

It also allows you to construct an optional templating engine replacing tags that you define :]
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Arta

#7
Quote from: Blaze on June 17, 2005, 09:16 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:


if(false)
{
   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.

Warrior

sometimes 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.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Arta

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.

Lenny

Well 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?

Quote
5
4
3
2
1

I'm having issues where window.setTimeout() and window.setInterval() only fire once with document.write()'s...
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.