Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML page that save its content, replacing the HTML file itself

I've to create a html page that auto-save its content.

This page is just a report of the activities of 4 days, that should be updated by some user.

enter image description here

This page will be used just for 3/4 days (Go live summary status page, and this say i all).. So I don't wanna lose time with backend, but I wanna do something like a trick just on client side, Javascript and HTML.

What I would like to do:

A user access to the page, this page is published on our internal server, update the status of the task and save the page! I thought to do this in two ways:

  • Any time I press the save button it just replace the old html content with the new one (replacing the html file itself)
  • Save the content in a plan file that will be loaded everytime the page is used, this second option obviously costs a lot of more work..

Any suggestion? I meant, is there something that help me doing this in just few time? I've about 2 days to finish this :(

UPDATE: Guys maybe i'm not explaining myself so good, am i thinking so wrong if i suppose just something like this:

Javascript function that when you click the save button replace the old html server file with the new one containing the row updated...

Easy easy easy...! I'm a backend developer.. not a lot of experience with beautiful styled front end pages :)

UPDATE: By your answer i'm assuming that is NO WAY to do this, without a backend side logic, even if light one, but its not possible to achieve this just with a client side scripting.. I already thought at this, but i was hoping there is some kind of trick that allows to do this without place anything on the server side.. :(

like image 640
ivoruJavaBoy Avatar asked Jun 17 '16 10:06

ivoruJavaBoy


People also ask

How do I save changes to my HTML page?

Your first instinct may be to hit the Escape key, but this will back you out of editing while discarding your changes. You can ensure your changes save by hitting Ctrl+Enter or simply clicking outside of the text box you are editing. HTML edits can be undone or redone using the normal Ctrl+Z and Ctrl+Y hotkeys.

What happens when you save a webpage as HTML?

Webpage, complete also downloads the entire webpage, but places all images into a separate folder. Webpage, HTML only saves the HTML code, which doesn't include any images—just the raw code, which you can use as reference for your own webpages.

What is in index HTML?

The index. html page is the most common name used for the default page shown on a website if no other page is specified when a visitor requests the site. In other words, index. html is the name used for the homepage of the website.


1 Answers

Finally, because we can use PHP we decided to do this: we put this in a file called "prova.php" and we launch this. This file shows the content of 'file.html' and save in 'salva.php' sending the data to save.

 <?php include('file.html');?> 

 some added string
 </div> 

 <button onclick="save()">SAVE</button> 

 <script> 


 function save(){ 

 var newData=document.getElementById("myText").innerHTML; 
 $.post( "salva.php", { data: newData} ); 
 } 
 </script>

The file to save called salva.php, receive the string and save in an existing file called "file.html".

<?php


$stringa=$_POST['data'];

$ourFileName = "file.html";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fwrite($ourFileHandle,$stringa);
fclose($ourFileHandle);


?>

file.html is a file that contains nothing at the beginning

like image 136
CiroRa Avatar answered Sep 22 '22 13:09

CiroRa