MetaChat REGISTER   ||   LOGIN   ||   IMAGES ARE OFF   ||   RECENT COMMENTS




artphoto by splunge
artphoto by TheophileEscargot
artphoto by Kronos_to_Earth
artphoto by ethylene

Home

About

Search

Archives

Mecha Wiki

Metachat Eye

Emcee

IRC Channels

IRC FAQ


 RSS


Comment Feed:

RSS

11 September 2007

Dumb HTML question: Is there (without using frames) an HTML equivalent to the include command in PHP? Basically, something that would load info from another page into that page?
Or, is javascript the easiest way to do this...?
posted by drezdn 11 September | 11:06
If your server supports them, and it probably does, you can use Server-Side Includes, after renaming your .html page to .shtml.

If iframes are out, then JavaScript is the way forward. 'Ajax' is the buzzword for this technique. Finding a lightweight JavaScript library which handles the ins and outs of xmlHttpRequest for you will probably help; mootools and mochikit are both good.
posted by matthewr 11 September | 11:25
This is the single most annoying exclusion from the html standard.
posted by mischief 11 September | 12:48
The simplest (though non standards compliant and completely hacky) way to do this is to put <script src="whatever.js"></script> into your main document. Your whatever.js needs to look like this:

document.write('<b>text to import</b>');

If you have lots to import you can either stuff it all into one command or use multiple document.write commands;
posted by cillit bang 11 September | 13:36
Is their anyway to use the javascript script to open a php file?

Right now, I'm working between 2 sites. On one, I can run php, and am using it to create pages from a MySQL database.


I'd like to be able to load content created by the php onto the site that can't run php, ideally into a page that already exists.
posted by drezdn 11 September | 13:52
You don't need to do anything special, just have the script tag link to you PHP, and insert the document.write commands into the text outputted by the PHP script. Use PHP's addslashes() function around your text to make sure quote marks in your text don't mess up the javascript syntax.

eg:
echo "<b>drezdn's text&lt/b>";

becomes:
echo "document.write('".addslashes("<b>drezdn's text&lt/b>")."');\n";

which when loaded should output:
document.write('<b>drezdn\'s text&lt/b>');
posted by cillit bang 11 September | 14:25
All of this viral corporate advertising is confusing me. || What software can I use to open & manipulate a .ani file?

HOME  ||   REGISTER  ||   LOGIN