Forum Moderators: open

Message Too Old, No Replies

WYSIWYG Editor help

Needing Undo and Redo for IE6

         

bootcom_uk

6:15 am on Nov 28, 2003 (gmt 0)

10+ Year Member



I have been working on a WYSIWYG editor for usage with IE 5.5 and above (I currently have it online at <snip>). Using IE6 I can not undo or redo previous commands (from what I can gather theres a bug or 2 in IE6). All I am really wanting to know is whether or not there is another way I can do these commands?

[edited by: korkus2000 at 3:17 am (utc) on Nov. 30, 2003]
[edit reason] No code/site reviews please [/edit]

RonPK

9:31 pm on Nov 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What command are you using? AFAIK, document.execCommand("Undo") works just fine. Or press Ctrl-Z ;)

Btw, posting URLs this way is against this site's TOS...

bootcom_uk

4:06 am on Dec 1, 2003 (gmt 0)

10+ Year Member



ooops ... sorry about the site link.

Ive been using the execCommand("undo") function but it doesnt seem to work in ie6, so im looking for a way around this, any ideas?

RonPK

9:16 am on Dec 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, by the way!

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.

bootcom_uk

10:14 am on Dec 1, 2003 (gmt 0)

10+ Year Member



Thanks for the reply, I have already tested this method but It wont work. I'm not using a textarea, Im using an Iframe and no matter what I do it just wont work. I know of many other people who have experienced this problem and just cant figure out how to sort.

DrDoc

4:09 pm on Dec 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How are you calling the execCommand command? And from where? From the parent document, or from the iframe?

bootcom_uk

5:39 pm on Dec 1, 2003 (gmt 0)

10+ Year Member



Im calling the function from the parent, like so

<div class='btnCtrl' onclick="editbox.document.execCommand('Undo');" onmouseover="eButton(this, 'over'); eStat('Undo previous command.');" onmouseout="eButton(this, 'out'); eStat('&nbsp;');" 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

RonPK

9:39 pm on Dec 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does Ctrl-Z work in your situation? That would help determine whether the problem is caused by the script or by something beyond control.

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.

bootcom_uk

7:58 am on Dec 2, 2003 (gmt 0)

10+ Year Member



Estat is not 'the' status bar. Estat is a div at the bottom of my editor, where when a user has their mouse over a button, the function appears.

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>