/    Sign up×
Community /Pin to ProfileBookmark

CTRL + Z through javascript

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

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriFeb 10.2004 — 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.
Copy linkTweet thisAlerts:
@daf5431authorFeb 10.2004 — 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.
Copy linkTweet thisAlerts:
@96turnerriFeb 12.2004 — <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>
×

Success!

Help @daf5431 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...