...">

Call one html file from another

I want to call one html page fron another in a div.

I tried to use

<include file="NavigationTree.html" />

and

<? include("/starfix/pages/NavigationTree.html"); ?>

But that will not work. Am I doing something wrong or do I need to do it differently?

+3
source share
4 answers

You might want to use Server Side Includes (SSI).

You put your HTML snippet in a separate file, for example NavigationTree.html, and then just link to it on your web pages using:

<!--#include virtual="NavigationTree.html" -->

SSI is supported by all popular web servers, including Apache, IIS, and lighttpd.


: , .shtml, .stm .shtm SSI. root- -, SSI , html.

+6

HTML.

- , , HTML, , .

PHP. , , include() .

:

<? include("./NavigationTree.html"); // will work if it in the same directory ?>

, , , :

<? include("/path/to/your/www/dir/starfix/pages/NavigationTree.html"); ?>

( -)

, HTTP:

 

, .

SSI, @Daniel.

+3

You can also use jQuery for this,

eg.

<div id="yourDiv" />
<script> 
$("#yourDiv").load("NameOfYourPageToReadFrom.ext #NameOfDivToReadFrom");
</script>

This puts the contents of the “NameOfDivToReadFrom” DIV in the called “NameOfYourPageToReadFrom” file into the loaded DIV ('yourDiv') in your current file.

Remember to add a definition to the header of your html.

eg.

<head>
       <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head> 
0
source

You can use iframefor this, for example:

<iframe width="500" height="300" frameborder="no" scrolling="no" marginheight="0"   marginwidth="0" 
src="http://www.example.com/page.html"></iframe>
-1
source

Source: https://habr.com/ru/post/1744909/


All Articles