Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript execCommands help??

Status
Not open for further replies.

codeone

Programmer
Mar 25, 2003
343
US
I can't believe I can't get this and I am stumped...

I'm trying to add the paste/redo/undo/cut functions in my script but nothing I do works, I got copy and select all working but the rest wont work...

here's my code:

Code:
<html>
<head>

</head>

<body>
<form name="script">
<textarea name="content" cols=10 rows=10 style="position:absolute; left:0; top:22;"></textarea>
<div>
<br>
<table border=0 style="position:absolute; left:150; top:22;">
<td>
<a href="#" onClick="">Cut</a> <div>
<a href="#" onClick="">Paste</a> <div>
<a href="#" onClick="">Redo</a> <div>
<a href="#" onClick="">Undo</a> 
</td>
</table>
</body>
</html>

I'm using IE6 and this does not have to be compatible with anything other than IE.

Note: I used document.execCommand('blah') in the onClick event statement and it did not work, I used variables, I specified the textarea to the exact address in my scripts and still nothing.

Hopefully someone has encountered this and has a quick fix, would be greatly appreciated...

regards

co
 
man I saw that and I can't believe that crap!!! Why the heck do they restrict commands???? Alrighty then..thanks anyway.

co
 

I seem to remember a post a while back - maybe 1 to 2 months or so... Not sure if it was here or in the HTML forum. Basically, it was talking about the undo function, and how it worked but in a limited fashion.

Try searching the forums for "undo"... It should turn up.

Hope this helps,

Dan
 
I thought M$ said IE6 didn't support the undo command...

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">

<html>
<head>
	<title></title>
</head>

<body>
<form name="script">
<textarea cols=20 rows=20></textarea>
<button onclick="execCommand('undo')">undo</button>
</form>
</body>
</html>

Anyone have IE6 see if that works for you.

Now that we know that IE6 does support execCommand('undo') how would I call that from a javascript and make sure it tests out in IE6, please...

regards
 
nevermind guys I got it and all is well...

thanks
 
Building functionality such as REDO UNDO(save and load) is possible with a little javascript and a meta tag.
mabye only works in IE try it click save then type something then click load/ it should disapear

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html>
<head>
<meta name=vs_targetSchema content="HTML 4.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<META NAME="save" CONTENT="snapshot">
<STYLE>
.saveSnapshot {behavior:url(#default#savesnapshot);}
.inviso {width:0px;height:0px;border:0px}
.show {dispay:block}
.hide {display:none}
</STYLE></head>
<BODY id="Bel" class="saveSnapshot">
<!--Persistable User data variables-->
<script>
var FPersist="";
var SPersist="";
var BPersist="";
//Save all User Input Data
function SaveBel(){
window.STop.click;
window.SBottom.click;
}
//function for Loading both the bottom and the top divs into memory for Building
function LoadBel(){
BPersist = FPersist + SPersist;
BPersist = BPersist + Bel.innerHTML;
}
</script>
<div id="htmlArea" style="DISPLAY:block">
<table id="TABLE1" style="WIDTH: 683px; HEIGHT: 25px"><tr><td align="left">Build Only

HTML that is in the body!</td><td align="right">
Only HTML that is in the body!</td></tr></table>
<table style="WIDTH: 708px; HEIGHT: 461px"><tr><td><textarea id="TopBody" cols="19"

rows="6" class="saveSnapshot" style="WIDTH: 241px; HEIGHT: 210px"></textarea>

<br>Click to save Top:<br><input TYPE="button" VALUE="Save"

onclick="FPersist=TopBody.innerText;" ID="STop"><br>Click to load Top:<br><INPUT

TYPE="button" VALUE="Load Top" onclick="TopBody.innerText=FPersist;"

ID="LTop"></td><td><textarea id="EndBody" cols="6" rows="10" class="saveSnapshot"

style="WIDTH: 219px; HEIGHT: 189px"></textarea>
<br>Click to save Bottom:<br><input type="button" value="Save"

onclick="SPersist=EndBody.innerText;" id="SBottom"><br>Click to load

Bottom:<br><input type="button" value="Load Bottom"

onclick="EndBody.innerText=SPersist;" id="LBottom">
</body></html>
 
Hey,

I looked at your script and what exactly does it do...lol

looks complicated but I couldn't figure out how it worked, I didnt look at the code that well, but from the looks of it, this script is not what I was looking for, or may be overkill, for what Im tryingto accomplish, however, thank you for posting that example, purhaps someone will come along and make use of it, so thanks alot!!!

regards

co
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top