Full version: jsB@nk » Utility » Undo-Redo script
URL: https://www.javascriptbank.com/undo-redo-script.html
Give your users the option of changing their entries in your textareas. Add this JavaScript to your forms or use it in a WYSIWYG editor.
Full version: jsB@nk » Utility » Undo-Redo script
URL: https://www.javascriptbank.com/undo-redo-script.html
<script type="text/javascript">// Created by: Turnea Iulian :: http://www.eurografic.rofunction iObject() { this.i; return this;}var myObject=new iObject();myObject.i=0;var myObject2=new iObject();myObject2.i=0;store_text=new Array();//store_text[0] store initial textarea valuestore_text[0]="";function countclik(tag) { myObject.i++; var y=myObject.i; var x=tag.value; store_text[y]=x;}function undo(tag) { if ((myObject2.i)<(myObject.i)) { myObject2.i++; } else { alert("Finish Undo Action"); } var z=store_text.length; z=z-myObject2.i; if (store_text[z]) { tag.value=store_text[z]; } else { tag.value=store_text[0]; }}function redo(tag) { if((myObject2.i)>1) { myObject2.i--; } else { alert("Finish Redo Action"); } var z=store_text.length; z=z-myObject2.i; if (store_text[z]) { tag.value=store_text[z]; } else { tag.value=store_text[0]; }}// --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name=form1> <input type="button" class="red" value="Undo" onmousedown="undo(document.form1.text1);"> <input type="button" class="red" value="Redo" onmousedown="redo(document.form1.text1);"> <br> <textarea rows=7 cols=50 name=text1 onkeydown="countclik(document.form1.text1);" > </textarea></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->