I was wondering if JavaScript has the ability to write to the file that is open in the browser. I'm developing a page of links to myself to some key websites that I use (for fun, not necessity). Currently I'm trying to develop something where the user can type a link and a name in textboxes and have the link be saved into the HTML file itself. It is obviously easy to add the link and the name to the page with JavaScript, but clearly once the session expires the link will not be added when the page is accessed again. I want to do it this way because I don't want to have to find and load the file every time I want to add a new link. This would be very easy to accomplish using PHP and MySQL, but this file is not running on a server.
So, in summary, is it possible to save the file once it has been modified by the current session?
My code is below:
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript">
function add(link,name)
{
htmlstring = "<a href='"+link+"'>"+name+"</a>";
document.getElementById('urlsdiv').innerHTML += htmlstring;
}
</script>
</head>
<body>
<input type = "button" onclick = "validate(document.getElementById('validbox').value)" value = "check">
<div id = "urlsdiv">
<input type = "text" id = "addbox">//Box to type new URL
<input type = "text" id = "addname">//Box to type link name
<input type = "button" onclick = "add(document.getElementById('addbox').value,document.getElementById('addname').value)" value = "Add">//Add new link to page
<a href = "https://www.facebook.com">Facebook</a>//These three links
<a href = "http://www.youtube.com">YouTube</a>//have already been hard-coded
<a href = "https://mail.google.com">Gmail</a>//into the file
</div>
</body>
</html>