Hi,
I'm trying to implement the undo and redo methods on my custom context menu, they both work okay on a simple example (hyperlinks beside a textarea), but not when incorportated into my context menu?
Any ideas will be most appreciated
Here is what I have, -
Note: I've not included all the images and stuff, let me know if you need them and I'll zip them up and attach them
Cheers Al
I'm trying to implement the undo and redo methods on my custom context menu, they both work okay on a simple example (hyperlinks beside a textarea), but not when incorportated into my context menu?
Any ideas will be most appreciated

Here is what I have, -
Note: I've not included all the images and stuff, let me know if you need them and I'll zip them up and attach them
Code:
<html> <head> <script language="JavaScript1.2"> <!-- function ProperCase(STRING){ /* list of ASCII codes - http://www.robelle.com/library/smugbook/ascii.html Source - http://www.apriori-it.co.uk/PCase.asp Modified - by Allan Conybeare to handle the apostrophe in names */ var strReturn_Value = ""; var iTemp = STRING.length; if(iTemp==0){ return false; } var UcaseNext = false; strReturn_Value += STRING.charAt(0).toUpperCase(); for(var iCounter=1;iCounter < iTemp;iCounter++){ if(UcaseNext == true){ strReturn_Value += STRING.charAt(iCounter).toUpperCase(); } else { strReturn_Value += STRING.charAt(iCounter).toLowerCase(); } var iChar = STRING.charCodeAt(iCounter); // 32=Space, 45=-, 46=. if(iChar == 32 || iChar == 45 || iChar == 46){ UcaseNext = true; } else { UcaseNext = false; } // 99=c, 67=C, 77=M, 109=m, 39=' if(iChar == 99 || iChar == 67){ if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){ UcaseNext = true; } } // 39=', 79=O - Handle names like O'Connell, O'Brien, O'Donnell, O'Driscal etc. if(iChar == 39) { if(iCounter >= 1) { if(strReturn_Value.charCodeAt(iCounter-1) == 79){ UcaseNext = true; } } } } //End For return strReturn_Value; } //End Function function LowerCase(STRING){ var strReturn_Value = ""; var iTemp = STRING.length; if(iTemp==0){ return false; } strReturn_Value = STRING.toLowerCase(); return strReturn_Value; } //End Function function UpperCase(STRING){ var strReturn_Value = ""; var iTemp = STRING.length; if(iTemp==0){ return false; } strReturn_Value = STRING.toUpperCase(); return strReturn_Value; } //End Function function doSelectAll(theField) { theField.focus() theField.select() } var copiedtext="" var tempstore="" function doCopy() { if (document.all){ tempstore=copiedtext document.execCommand("Copy") copiedtext=window.clipboardData.getData("Text"); } } function doCut() { if (document.all){ tempstore=copiedtext document.execCommand("Cut") copiedtext=window.clipboardData.getData("Text"); } } function doPaste(theField) { // pastes at the cursor and or replaces a selection if (document.all){ theField.focus() document.execCommand("Paste") } } function doUndo() { //object.execCommand(sCommand [, bUserInterface] [, vValue]) document.execCommand("Undo", false, null); } function doRedo() { //object.execCommand(sCommand [, bUserInterface] [, vValue]) document.execCommand("Redo"); } // --> </script> </head> <body topmargin="50" leftmargin="20"> <!--Begin Context Menu --> <script language="JavaScript1.2"> <!-- /* Context Menu script II (By Dheera Venkatraman at [email protected]) Submitted to Dynamic Drive to feature script in archive For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com */ var isie=0; if(window.navigator.appName=="Microsoft Internet Explorer"&&window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE")+5,window.navigator.appVersion.indexOf("MSIE")+8)>=5.5) { isie=1; } else { isie=0; } if(isie) { var html=""; html+='<table style="border:1pt solid #808080" bgcolor="#cccccc" width="140" height="220" cellpadding="0" cellspacing="1">'; html+='<st'+'yle type="text/css">\n'; html+='a:link {text-decoration:none;font-family:Arial;font-size:8pt;}\n'; html+='a:visited {text-decoration:none;font-family:Arial;font-size:8pt;}\n'; html+='td {font-size:8pt;}\n'; html+='</st'+'yle>\n'; html+='<sc'+'ript language="JavaScript">\n'; html+='\n<'+'!--\n'; html+='window.onerror=null;\n'; html+='/'+' -'+'->\n'; html+='</'+'script>\n'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i0" onmouseover="document.all.i0.style.background=\'#CFD6E8\';document.all.i0.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i0.style.background=\'#CCCCCC\';document.all.i0.style.border=\'1pt solid #CCCCCC\';" onclick="parent.el.value = parent.ProperCase(parent.el.value); parent.oPopup.hide();"> ProperCase</td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i1" onmouseover="document.all.i1.style.background=\'#CFD6E8\';document.all.i1.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i1.style.background=\'#CCCCCC\';document.all.i1.style.border=\'1pt solid #CCCCCC\';" onclick="parent.el.value = parent.UpperCase(parent.el.value); parent.oPopup.hide();"> UpperCase</td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i2" onmouseover="document.all.i2.style.background=\'#CFD6E8\';document.all.i2.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i2.style.background=\'#CCCCCC\';document.all.i2.style.border=\'1pt solid #CCCCCC\';" onclick="parent.el.value = parent.LowerCase(parent.el.value); parent.oPopup.hide();"> LowerCase</td></tr>'; html+='<tr><td style="border:1pt solid #CCCCCC"><img src="images/pixel.gif" width="130" height="1"></td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i3" onmouseover="document.all.i3.style.background=\'#CFD6E8\';document.all.i3.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i3.style.background=\'#CCCCCC\';document.all.i3.style.border=\'1pt solid #CCCCCC\';" onclick="parent.doCut(parent.el); parent.oPopup.hide();"><table width="100%"><tr><td> <img src="images/cut.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle"> Cut </td><td>Ctrl+X</td></tr></table></td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i4" onmouseover="document.all.i4.style.background=\'#CFD6E8\';document.all.i4.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i4.style.background=\'#CCCCCC\';document.all.i4.style.border=\'1pt solid #CCCCCC\';" onclick="parent.doCopy(parent.el); parent.oPopup.hide();"><table width="100%"><tr><td> <img src="images/copy.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle"> Copy</td><td>Ctrl+C</td></tr></table></td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i5" onmouseover="document.all.i5.style.background=\'#CFD6E8\';document.all.i5.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i5.style.background=\'#CCCCCC\';document.all.i5.style.border=\'1pt solid #CCCCCC\';" onclick="parent.doPaste(parent.el); parent.oPopup.hide();"><table width="100%"><tr><td> <img src="images/paste.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle"> Paste</td><td>Ctrl+V</td></tr></table></td></tr>'; html+='<tr><td style="border:1pt solid #CCCCCC"><img src="images/pixel.gif" width="130" height="1"></td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i6" onmouseover="document.all.i6.style.background=\'#CFD6E8\';document.all.i6.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i6.style.background=\'#CCCCCC\';document.all.i6.style.border=\'1pt solid #CCCCCC\';" onclick="parent.doSelectAll(parent.el); parent.oPopup.hide();"><table width="100%"><tr><td> Select All</td><td>Ctrl+A</td></tr></table></td></tr>'; html+='<tr><td style="border:1pt solid #CCCCCC"><img src="images/pixel.gif" width="130" height="1"></td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i7" onmouseover="document.all.i7.style.background=\'#CFD6E8\';document.all.i7.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i7.style.background=\'#CCCCCC\';document.all.i7.style.border=\'1pt solid #CCCCCC\';" onclick="parent.doUndo(); parent.oPopup.hide();"><table width="100%"><tr><td> Undo</td><td>Ctrl+Z</td></tr></table></td></tr>'; html+='<tr><td style="cursor:hand; border:1pt solid #CCCCCC" id="i8" onmouseover="document.all.i8.style.background=\'#CFD6E8\';document.all.i8.style.border=\'1pt solid #737B92\';" onmouseout="document.all.i8.style.background=\'#CCCCCC\';document.all.i8.style.border=\'1pt solid #CCCCCC\';" onclick="parent.doRedo(); parent.oPopup.hide();"><table width="100%"><tr><td> Redo</td><td>Ctrl+Y</td></tr></table></td></tr>'; html+='</table>'; var oPopup = window.createPopup(); var el; } function dopopup(obj) { var lefter2 = event.offsetY+0; var topper2 = event.offsetX+15; el=obj; if(isie) { oPopup.document.body.innerHTML = html; oPopup.show(topper2, lefter2, 140, 220, el); } } // --> </script> <!-- End Context Menu --> <p> <table> <form name="theForm" id="theForm"> <tr> <td><input name="text1" id="text1" value="paul mccartney" oncontextmenu="dopopup(this); return false"></td> </tr> <tr> <td><textarea name="ta1" id="ta1" rows="10" cols="35" oncontextmenu="dopopup(this); return false">o'connell was here wasn't he?</textarea></td> </tr> </form> </table> </p> <p> <p>Check out a original context menu example click <a href="..\menu.html">here</a></p> <p> <b>Wish List:</b> Would be better if the case conversion functions only converted the selected text, as word etc. do!<br /> <b>Note:</b> Have added Undo and Redo but they're not working, they're okay in my simple example - suspect it might be something to do with the popup? </p> </body> </html>
Comment