Click to See Complete Forum and Search --> : CTRL + Z through javascript


daf5431
02-10-2004, 09:10 AM
Hi every1!

I'm working on a web content editor which needs the basic Undo button, found in most editors, like Word. Is there a way of "sending" the CTRL + Z command through javascript when the users clicks the Undo button on my web app??

Thanks.

/Peter

96turnerri
02-10-2004, 09:41 AM
What are you attempting to redo and undo. Some applications carry a `memory` that records what you are doing and will repeat the steps when prompted. A built feature does not exists in JavaScript.

daf5431
02-10-2004, 09:53 AM
Well.. see.. I use a textarea for the editing. If the user accidently deletes a word or a sentence, then instead of hitting the CTRL + Z keys on the keyboard to call the undo command he rather clicks an undo button that calls a javascript function that carries out the same operation as the keyboard command would.

I've found something called document.execCommand() but i can't quite figure it out.

96turnerri
02-12-2004, 05:22 AM
<script type="text/javascript">
function change() {
theText.focus();
document.execcommand("undo");
}
</script>
<textarea rows="10" cols="10" id="theText"></textarea>
<a href="javascript:change();">undo</a>