Reputation: 1669
I have an offline html file that contains documentation and I have to output content of text file (in my case it is source code). Is there a way to include content of this file to html page, using only client-side feature (HTML itself or JS)?
<html>
<head>
<style>
p.source_code
{
font-family:"Courier New"
}
</style>
</head>
<body>
<p>
Some content
</p>
<p class="source_code">
<!-- place for output content of file main.cpp -->
</p>
</body>
</html>
#include <stdio.h>
int main()
{
printf("Hello World");
}
I want my page in browser looks like
Some content
#include <stdio.h>
int main()
{
printf("Hello World");
}
Upvotes: 3
Views: 19607
Reputation: 72642
You can simply use an iframe
if both the HTML file and the source file are local:
<html>
<head>
<title>Example</title>
</head>
<body>
<iframe src="the-file.txt">
</iframe>
</body>
</html>
Upvotes: 4