Forum Moderators: open
[edited by: korkus2000 at 3:17 am (utc) on Nov. 30, 2003]
[edit reason] No code/site reviews please [/edit]
Are you sure there isn't some other problem? I've noticed that the undo-method doesn't allways do what you'd expect it to. But it usually works fine in my IE6.
<script type="text/javascript">
function unndoo() {
theText.focus();
document.execCommand("Undo");
}
</script>
<textarea rows=5 cols=20 id=theText></textarea>
<a href="javascript:unndoo()">undo</a>
No problems over here.
<div class='btnCtrl' onclick="editbox.document.execCommand('Undo');" onmouseover="eButton(this, 'over'); eStat('Undo previous command.');" onmouseout="eButton(this, 'out'); eStat(' ');" onmousedown="eButton(this, 'down');" onmouseup="eButton(this, 'up');">
<img width='23' height='22' hspace='1' vspace='1' align='absmiddle' src='images/undo.gif' alt='Undo'></div>
This works for all other execCommand functions (well the ones I have tried) just not undo and redo
Could it be that your functions eButton and eStat mess with the undo history? I tried replacing them by writing something to the status bar directly, but that did not stop Undo from working. I created an iframe with ID 'editbox'. IE6 SP1 and lots of patches; Windows ME.
Ebutton is the function which makes the image look more like a button, with depth and hover controls.
Anyway, tried your suggestion and it looks like one of the above controls is messing with the undo/redo lists so I will need to find another way around it. Worked fine when I used the following code.
<html>
<head>
<script>
function loadEditor(){
//----- Modify User Controls -----
editbox.document.designMode="On";
}
</script>
</head>
<body onLoad="loadEditor()">
<a href="#" onClick="editbox.document.execCommand('undo')">undo</a>
<a href="#" onClick="editbox.document.execCommand('redo')">redo</a>
<iframe id='editbox' name='editbox' style="width: 100%; height:100%"></iframe>
</body>
</html>