5542 sujets

Sémantique web et HTML

Bonjour
J'ai créé une première page HTML embarqué dans un composant serveur ESP8266 qui s'affiche à la demande d'un client (PC ou tablette).
Le serveur peut nécessiter une configuration, si le client le demande.
J'ai donc créé une deuxième page avec les options de configuration.
Le programme du serveur recevant la demande de configuration devrait envoyer la nouvelle page, mais, bien que le processus semble bien se dérouler, c'est toujours la première page qui est affichée.
Ma question: y a-t'il une commande spéciale que doit recevoir le client pour fermer une fenêtre avant d'en ouvrir une nouvelle?
Merci d'une aide éventuelle.
Voici la page HTML initiale. Lorsque le serveur reçoit un POST avec le message "configuration", il envoie une deuxième page HTML sensée permettre l'entrée de la configuration. J'ai contrôlé, l'envoi de la deuxième page s'effectue bien mais ne s'affiche pas sur le client.
<!DOCTYPE html>
<!--*****************Balisage chargé dans la mémoire SPIFFS d'un ESP8266************-->
<html>
<head>
<title>ESP8266 Web Sever</title>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJ
cEhZcwAADsQAAA7EAZUrDhsAAAABYktHRACIBR1IAAAAB3RJTUUH2gsEDgIHIQ/phAAABwJJREFUaEPdmm1sFEUY
x/+7d71rr+2VAqX2eCu0hIQSCLG8tIVoSVARFIixkPhBIVo0Gm1Bo0BM/AAxgciLGqEQ0C8mhUhCoEgAkQAFS5Rg
FNBCrQGl0CvQUtper3d76zOzs9e96/auPUpb/KVPdmb2Zp//MzM7M7tb6fTpk6rf54cpkiQSJqiqSJhgVq+3v9cx
qadSWWJyEmbOyIPcrfhYICGq1QrFboc/IYEskczB86w8otBeEggE+FH68cTx7psmWsvIEhSbHYolgRfJrQoSav5F
8uWrSGi8BauvBX5rIjypLrTkTEDrhNFQEy2wKB7+e0uHl5TQdWLogYTEROTNyo8tAJUJp9bFAwmu8sNw1R/k5amZ
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ICCjxjRwF/8LIeIGGBuCkZ+ZTO1rsyIrHWE5A+T+YorldHC0AJoG28C7jEcob+iUA23ZSsMRlFlO4psdVjmsh+
B9rGubheneB7Ia9jOAq3PAP73gZWzIoGEVqjepem4WTpMdhaG/6H74UsaIe7vVDkBif1nkKu00hnAD4vbha+CHzH
cmLMDQpIB9NEVjd3EddpJBiA5POhqWAyvLuHiZLBg3f3cG5NBTlcp5GQN3NW3wNUZ64CrlCG2WCAdFRnlnJj+sIJ
eTNn8bbj5usvoOONVG79P4zC/anoKB7KNTFj+sIJnYWovq3tHn4u2skNn4vCfsM4fZNf8s90ME3MzKR0mUZlGmOt
szO51R5d3vkxor+hx5PaoyvQWjCWa2JmRpcAGHHNTdyq15ei6aVptMnrz14gyF/jkmnkv4TriIRpALyryOz3G1D1
xR605NKTRH8FQX5anszC+S+/5v6jjWDzAARs12fzNqJy+37cm5VLj1AiskcCXfcatfzMXFTu2E9+74bsOrsj6gcO
KRCAzXMX58v2oGb128AGVtqXgYhr0cN9zaq3ULVrD/enfydj38MiEbEHHgcifqHRYV0Z3+RG7cev4kz6IXhyRwKV
7IxovV6j1yM7RVvk6aNxOuMQaj9ZjvhGd3DoqGoATmcK74XueqLX34nZZ5+OpGEYUX4KEy9uQdLCv4A3xcmQ15Zh
c7oOW4vKtGRLxXhUT18N98tzYGu5B9nf9d8eVBrCUpiOmL4Th8NesvpsyXD8WYeMgxW8LN1/Ck4Xrf00aWEcGdtW
0fqDv8lqgeZbOXArc1C3ZCEVUMtPGok4bzPkDvM5nmPS8n0SgH5h1WqhYLQXropkh9SuwtpwH/G37yDufjM9wzrh
yRgG//AhUOMl2g53kGBtSyD5xaNhD/wYCQngxA/HHiqALlAVVbaQ0fzA6tPv2EzGn2O789RbP1QW73AgP382/gNr
4NdhiWeTAwAAAABJRU5ErkJggg=="/>
<!--******************************************************************************-->
<script type="text/javascript">
function action(num, btn, pou) {
// *******************toggle class***************
var myButton = btn;
var myPou = pou;
var className = " " + myButton.className + " ";
if (~className.indexOf(" ex1 ")) {
btn.className = className.replace(" ex1 ", " ex2 ");
}
else {
btn.className = className.replace(" ex2 ", " ex1 ");
}
// *******************fin toggle class***********
var msg = "";
if (myPou) {
msg = "/btn" + num + "/pou!";
}
else {
msg = "/btn" + num + "/non!";
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "/");
xhr.send(msg);
}
<!--**********lance une demande de mise à jour des paramètres******-->
setInterval(function(){maj();},30000);
function maj(){
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200){
var temp = this.responseText.substr(0,5);
temp = temp.replace(".",",");
var humi = this.responseText.substr(5,5);
humi = humi.replace(".",",");
var pres = this.responseText.substring(10);
pres = pres.replace(".",",");
document.getElementById("Temp").innerHTML = "La température est: " + temp + " °C";
document.getElementById("Humi").innerHTML = "L'humidité relative est: " + humi + " %";
document.getElementById("Pres").innerHTML = "La pression atmosphérique est: " + pres + " hPa";
majHeure();
}
};
xhr.open("POST", "/");
xhr.send("/param");
}
</script>
<script type="text/javascript">
<!--********lance la demande de page de configuration***************-->
function configuration(){
var xhr = new XMLHttpRequest();
xhr.open("POST", "/");
xhr.send("/config");
}
<!--********envoi une mise à jour de l'heure*************************-->
function majHeure(){
var d = new Date();
var mois =["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"];
var jour =["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"];
var dateActuel = jour[d.getDay()] + " " + d.getDate() + " " + mois[d.getMonth()] + " " + d.getFullYear() + " à " + d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
document.getElementById("horloge").innerHTML = "Mise à jour le " + dateActuel;
}
</script>
</head>
<!--***********************************************************************-->
<style>
.ex1, .ex2 {
width: 110px;
padding: 6px;
color: white;
background-color: skyblue;
display: inline;
margin: 2px;
border: none;
border-radius: 4px;
text-decoration: none;
font-size: 16px;
cursor: pointer;
}
.ex2 {
background-color: red;
}
.ex3 {
border-style: double;
border-color: MediumSeaGgreen;
width: 500px;
padding: 20px;
margin: auto;
background-color: AliceBlue;
text-align: left;
}
html {
font-family: Arial;
display: inline-block;
margin: 0px auto;
text-align: center;
}
h1 {
color: #0f3376;
padding: 2vh;
}
h2 {
font-size: 13px;
font-style: italic;
}
p {
font-size: 1.5rem;
}
label {
font-size: 12px;
margin: 10px;
}
.button {
cursor: pointer;
}
.button:hover {
background-color: green;
}
.button:active {
background-color: black;
}
</style>
<!--*******************************************************************-->
<body>
<h1>Thermo/Hygro/Baro-mètre</h1>
<h2 id="horloge"> Date et heure de mise à jour</h2>
<p style=font-size:12px>Etat des commandes</p>
<div> <p class="ex1">Off</p> <p class="ex2">On</p> </div>
<br></br>
<button onclick="configuration()">Configuration</button>
<br></br>
<!--****La fin du balisage est dans le prog de l'ESP8266*******************--><div>
<button class="button ex1" id="btn0" onclick= "action(0,this,0)">Interrupteur 1</button>
<button class="button ex1" id="btn1" onclick= "action(1,this,1)">Poussoir 2</button>
<button class="button ex1" id="btn2" onclick= "action(2,this,0)">Interrupteur 3</button>
<button class="button ex1" id="btn3" onclick= "action(3,this,0)">Interrupteur 4</button>
</div>
<p id="message">Commande manuelle: appuyer sur la touche désirée</p><br><br><p class="p ex3" id="Temp">La température est: 24,96 °C </p><br><br><p class="p ex3" id="Humi">L'humidité relative est: 36,73 %</p><br><br><p class="p ex3" id="Pres">La pression atmosphérique est: 995,91 hPa</p></body></html>
Voici la deuxième page sensée permettre l'entrée de la configuration.

<!DOCTYPE html>
<!--*****************Balisage chargé dans la mémoire SPIFFS d'un ESP8266************-->
<html>
<head>
<title>Config Web Server</title>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
td input {
width: 70px;
text-align: center;
}
table {
border-collapse: collapse;
margin: 1em;
border: solid 3px;
border-width: 2px;
}
table td{
padding: 10px;
}
button {
padding: 10px;
position: relative;
}
</style>
<h1>Configuration des commandes</h1>
<p><b>Commande 1:</b>&emsp;&emsp; mode de fonctionnement
<input type="radio" id="int1" name="switch1" checked="checked">
<label for="int1"> Interrupteur </label>
<input type="radio" id="pou1" name="switch1">
<label for="pou1"> Poussoir </label>
</p>
<table style="background-color: lightblue">
<tr>
<th><input type="radio" id="com1" name="bouton1">
<label for ="com1"> Température</label></th>
<th><input type="radio" id="com2" name="bouton1">
<label for ="com2"> Humidité</label></th>
<th><input type="radio" id="com3" name="bouton1">
<label for ="com3"> Pression</label></th>
<th><input type="radio" id="com4" name="bouton1">
<label for ="com4"> Autre</label></th>
</tr>
<tr>
<td><label for="ton">Seuil_ON: </label><input type="number" placeholder="°C" step="0.01" max="100" id="ton"></td>
<td><label for="hon">Seuil_ON: </label><input type="number" placeholder="%" step="0.01" max="100" id="hon"></td>
<td><label for="pon">Seuil_ON: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pon"></td>
<td><label for="aon">Seuil_ON: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aon"></td>
</tr>
<tr>
<td><label for="tof">Seuil_OF: </label><input type="number" placeholder="°C" step="0.01" max="100" id="tof"></td>
<td><label for="hof">Seuil_OF: </label><input type="number" placeholder="%" step="0.01" max="100" id="hof"></td>
<td><label for="pof">Seuil_OF: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pof"></td>
<td><label for="aof">Seuil_OF: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aof"></td>
</tr>
</table>
<br>
<p><b>Commande 2:</b>&emsp;&emsp; mode de fonctionnement
<input type="radio" id="int2" name="switch2" checked="checked">
<label for="int2"> Interrupteur </label>
<input type="radio" id="pou2" name="switch2">
<label for="pou2"> Poussoir </label>
</p>
<table style="background-color: lightgreen">
<tr>
<th><input type="radio" id="com1" name="bouton2">
<label for ="com1"> Température</label></th>
<th><input type="radio" id="com2" name="bouton2">
<label for ="com2"> Humidité</label></th>
<th><input type="radio" id="com3" name="bouton2">
<label for ="com3"> Pression</label></th>
<th><input type="radio" id="com4" name="bouton2">
<label for ="com4"> Autre</label></th>
</tr>
<tr>
<td><label for="ton">Seuil_ON: </label><input type="number" placeholder="°C" step="0.01" max="100" id="ton"></td>
<td><label for="hon">Seuil_ON: </label><input type="number" placeholder="%" step="0.01" max="100" id="hon"></td>
<td><label for="pon">Seuil_ON: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pon"></td>
<td><label for="aon">Seuil_ON: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aon"></td>
</tr>
<tr>
<td><label for="tof">Seuil_OF: </label><input type="number" placeholder="°C" step="0.01" max="100" id="tof"></td>
<td><label for="hof">Seuil_OF: </label><input type="number" placeholder="%" step="0.01" max="100" id="hof"></td>
<td><label for="pof">Seuil_OF: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pof"></td>
<td><label for="aof">Seuil_OF: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aof"></td>
</tr>
</table>
<br>
<p><b>Commande 3:</b>&emsp;&emsp; mode de fonctionnement
<input type="radio" id="int3" name="switch3" checked="checked">
<label for="int3"> Interrupteur </label>
<input type="radio" id="pou3" name="switch3">
<label for="pou3"> Poussoir </label>
</p>
<table style="background-color: wheat">
<tr>
<th><input type="radio" id="com1" name="bouton3">
<label for ="com1"> Température</label></th>
<th><input type="radio" id="com2" name="bouton3">
<label for ="com2"> Humidité</label></th>
<th><input type="radio" id="com3" name="bouton3">
<label for ="com3"> Pression</label></th>
<th><input type="radio" id="com4" name="bouton3">
<label for ="com4"> Autre</label></th>
</tr>
<tr>
<td><label for="ton">Seuil_ON: </label><input type="number" placeholder="°C" step="0.01" max="100" id="ton"></td>
<td><label for="hon">Seuil_ON: </label><input type="number" placeholder="%" step="0.01" max="100" id="hon"></td>
<td><label for="pon">Seuil_ON: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pon"></td>
<td><label for="aon">Seuil_ON: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aon"></td>
</tr>
<tr>
<td><label for="tof">Seuil_OF: </label><input type="number" placeholder="°C" step="0.01" max="100" id="tof"></td>
<td><label for="hof">Seuil_OF: </label><input type="number" placeholder="%" step="0.01" max="100" id="hof"></td>
<td><label for="pof">Seuil_OF: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pof"></td>
<td><label for="aof">Seuil_OF: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aof"></td>
</tr>
</table>
<br>
<p><b>Commande 4:</b>&emsp;&emsp; mode de fonctionnement
<input type="radio" id="int4" name="switch4" checked="checked">
<label for="int4"> Interrupteur </label>
<input type="radio" id="pou4" name="switch4">
<label for="pou4"> Poussoir </label>
</p>
<table style="background-color: lightpink">
<tr>
<th><input type="radio" id="com1" name="bouton4">
<label for ="com1"> Température</label></th>
<th><input type="radio" id="com2" name="bouton4">
<label for ="com2"> Humidité</label></th>
<th><input type="radio" id="com3" name="bouton4">
<label for ="com3"> Pression</label></th>
<th><input type="radio" id="com4" name="bouton4">
<label for ="com4"> Autre</label></th>
</tr>
<tr>
<td><label for="ton">Seuil_ON: </label><input type="number" placeholder="°C" step="0.01" max="100" id="ton"></td>
<td><label for="hon">Seuil_ON: </label><input type="number" placeholder="%" step="0.01" max="100" id="hon"></td>
<td><label for="pon">Seuil_ON: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pon"></td>
<td><label for="aon">Seuil_ON: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aon"></td>
</tr>
<tr>
<td><label for="tof">Seuil_OF: </label><input type="number" placeholder="°C" step="0.01" max="100" id="tof"></td>
<td><label for="hof">Seuil_OF: </label><input type="number" placeholder="%" step="0.01" max="100" id="hof"></td>
<td><label for="pof">Seuil_OF: </label><input type="number" placeholder="hPa" step="0.01" max="100" id="pof"></td>
<td><label for="aof">Seuil_OF: </label><input type="number" placeholder="<vide>" step="0.01" max="100" id="aof"></td>
</tr>
</table>
<br>
<button type="button" id="valide" style="left:20px; color:blue;" onclick="validation">Validation</input>
<button type="button" id="annule" style="left:100px; color:red;" onclick="annulation">Annulation</input>

</html>