JavaScript Notepad

[Total: 0    Average: 0/5]

This uses cookies to store your text.

Head Code:

<script>
function ReadCookie (Name)
{
	var search = Name + "="
	if (document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search)
		if (offset != -1)
		{
			offset += search.length 
			end = document.cookie.indexOf(";", offset) 
			if (end == -1)
				end = document.cookie.length
			return (document.cookie.substring(offset, end))
		}
		else
			return ("");
	}
	else
		return ("");
}

function WriteCookie (cookieName, cookieValue, expiry) 
{
	var expDate = new Date();

	expDate.setTime (expDate.getTime() + expiry);
	document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString() + "; path=/";
}

function getCookies()
{
	document.noteForm.note.value = unescape(ReadCookie("note"));
}

</script>

Body Code:

<CENTER><font face="Arial" size="5" color="#000000"><B>Java-Script / Notepad with Cookie</B></FONT><BR>
<form NAME="noteForm">
           <textarea ROWS="5" COLS="40" NAME="note" WRAP="VIRTUAL"></textarea><br>
      <b><font FACE="verdana,arial,helvetica" SIZE="-1"><BR><input TYPE="button" VALUE="Save Text"
      onClick="WriteCookie('note', document.noteForm.note.value, 2678400000)"></font> </b></p>
      </center></div>
    </form>
</font>
<script>
window.onload=function() { getCookies(); }
</script>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *