Avatar of finaris
finaris
Flag for Germany asked on

Including content in a HTML page

Hello Experts,

I would like to split a HTML based report into multiple parts (due to structural reasons).

The aim is to have a main HTML document, which includes data from other text/html files in the same directory.

As there is no INCLUDE command for plain HTML like in PHP (#include(<file>)), I need another solution for this.

Is it possible to include that data dynamically using a scripting language like JavaScript or using a similar approach?
If so, an example would be useful for me.


Please note:
- I have to deal with a very restrictive desktop environment which does not allow me to install additional software, or create/edit registry keys.
- If possible, the solution should be applicable on various operating systems (Windows, Linux, etc.)
JavaScriptHTMLPHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jon Norman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
cubaman_24

Hello:
You could use an XSLT transform to modify the original html file. This solution is fast, doesn't require higher privileges and is inter-operable
Chris Stanyon

Actually, there is an include directive for HTML files if your server is configured for it. Most are, but you may have to have a play around to figure out if yours is.

In your HTML file, you include a file like so:

<!--#include virtual="file-to-include.html" -->

It's called SSI (server side includes).

You may have to rename the extension of your file to shtml, depending on your server's setup.
Ray Paseur

Noting that you posted this question in the PHP Zone, do you have PHP available to you?  If so, you can use PHP to generate the HTML (as well as access the data model, receive and process client inputs, etc.)

See http://www.laprbass.com/RAY_html5.php
<?php // RAY_html5.php
error_reporting(E_ALL);

// CREATE A VARIABLE FOR OUR HTML
$xyz = 'Hello World';

// CREATE OUR WEB PAGE IN HTML5 FORMAT
$htm = <<<HTML5
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="iso-8859-1" />
<meta http-equiv="Expires" content="Mon, 01 Jan 1990 01:00:00 GMT" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<title>HTML5 Page</title>
</head>
<body>
<p>$xyz</p>
</body>
</html>
HTML5;

// RENDER THE WEB PAGE
echo $htm;

Open in new window

Your help has saved me hundreds of hours of internet surfing.
fblack61