Essaye comme ça :
fichier home.html
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE="javascript" >
var url = "accueil"
var search = new String( document.location.search);
if ( search!="" && search!="?" ) url= search.substring(1);
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript" >
document.write('<SCRIPT LANGUAGE="JavaScript" SRC="' + url + '.js">'
;
document.write('</'
;
document.write('SCRIPT>'
;
</SCRIPT>
</BODY>
</HTML>
fichier accueil.js
document.open();
document.write("<h1>Accueil</h1>" );
document.write("<a href='home.html?contenu1'>contenu 1</a><br>" );
document.write("<a href='home.html?contenu2'>contenu 2</a>" );
document.close();
fichier contenu1.js :
document.open();
document.write("<h1>Contenu 1</h1>" );
document.write("<a href='home.html'>Accueil</a><br>" );
document.write("<a href='home.html?contenu2'>contenu 2</a>" );
document.close();
Fichier contenu 2 :
document.open();
document.write("<h1>Contenu 2</h1>" );
document.write("<a href='home.html'>Accueil</a><br>" );
document.write("<a href='home.html?contenu1'>contenu 1</a>" );
document.close();
j'ai testé tout ça sous w2000 Server Us
avec :
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3
Etant donné que la page home.html s'appelle elle-même, la version en cache devrait être utilisée.
Ceci dit, j'ai du mal à comprendre l'interêt de la chose, puisque, même si la page n'est pas chargée à chaque contenu affiché, les fichiers .js eux le sont et sont plus lourds que leur version en html puisque qu'on ajoute le code js.
Néanmoins, c'est un bon exercice intelectuel
Pascal