Web Analytics Made Easy -
StatCounter Undo and Redo with Context Menu - CodingForum

Announcement

Collapse
No announcement yet.

Undo and Redo with Context Menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Undo and Redo with Context Menu

    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

    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();">&nbsp;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();">&nbsp;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();">&nbsp;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>&nbsp;<img src="images/cut.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;Cut&nbsp;&nbsp;</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>&nbsp;<img src="images/copy.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;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>&nbsp;<img src="images/paste.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;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>&nbsp;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>&nbsp;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>&nbsp;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>
    Cheers Al

  • #2
    It's funny you should ask that. After I sorted out the the paste function on another post of yours I thought "What about Undo?" One thing led to another and I came up with the following additional editing commands for your simpler example:
    Code:
    function Undo(theField) {
    	var tempval=eval("document."+theField)
    	if (document.all){
    		tempval.focus()
    		document.execCommand("Undo")
    	}
    }
    
    function Redo(theField) {
    	var tempval=eval("document."+theField)
    	if (document.all){
    		tempval.focus()
    		document.execCommand("Redo")
    	}
    }
    
    function Delete(theField) {
    	var tempval=eval("document."+theField)
    	if (document.all){
    		tempval.focus()
    		document.execCommand("Delete")
    	}
    }
    Activated like so (respectively):
    Code:
    <a class="highlighttext" href="javascript:Undo('test.select1')">Undo</a> |
    <a class="highlighttext" href="javascript:Redo('test.select1')">Redo</a> |
    <a class="highlighttext" href="javascript:Delete('test.select1')">Delete</a>
    Will that help in your more complicated example?
    - John

    Comment


    • #3
      jscheuer1,

      Thanks for your reply, I originally had my redo and undo functions exactly like yours but they didn't work, then tried them in my simple example still no joy so I changed them to how they are in the post above and they work in my simple example but not in my more complex guy.

      I've also just copied and pasted your functions in and tried them without any joy, but they work in my simple example don't know why they didn't when I first tried it

      If you're using IE you can test the code in my first post, still works without the images just isn't as pretty.

      [edit]
      I've put an alert in the undo and redo functions which fire. Also once you've called undo or redo from the context menu, Ctrl+Z or Ctrl+Y don't work
      Last edited by Running Bear; Aug 3, 2005, 11:39 AM.

      Comment


      • #4
        to see the context menu you need to right click over the textbox or textarea, right click anywhere else and you see the standard menu

        Comment


        • #5
          I'm nowhere near home with this one but, I've discovered that once you execute this statement:
          Code:
          oPopup.document.body.innerHTML = html;
          It empties the undo buffer or in some way disables undo. I discovered this by changing 'return false' to 'return true' in the oncontextmenu event for the text area. Even the default context menu which then also fires will not have 'undo' available unless the above line is removed from the code. A real problem because now we cannot write our context menu's code to the popup. I think there may be a DOM solution but, at this point I haven't been able to figure out how to append a text or element node to the oPopup object.
          - John

          Comment


          • #6
            OK, we are much nearer home now. That bit about using DOM was a little off but, I've ditched innerHTML in favor of document.write. It is counter intuitive but, with some fudging of styles, it worked well:
            Code:
            <html>
            <head>
            <script type="text/javascript">
            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(theField) {
            
            	if (document.all){
            		theField.focus()
            		document.execCommand("Undo")
            	}
            }
            
            function doRedo(theField) {
            
            	if (document.all){
            		theField.focus()
            		document.execCommand("Redo")
            	}
            }
            
            </script>
            
            </head>
            <body topmargin="50" leftmargin="20">
            
            <!--Begin Context Menu -->
            <script type="text/javascript">
            
            /*
            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;position:absolute;top:0;left:0;" 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();">&nbsp;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();">&nbsp;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();">&nbsp;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>&nbsp;<img src="images/cut.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;Cut&nbsp;&nbsp;</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>&nbsp;<img src="images/copy.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;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>&nbsp;<img src="images/paste.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;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>&nbsp;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.el); parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;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.el); parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;Redo</td><td>Ctrl+Y</td></tr></table></td></tr>';
            
            	html+='</table>';
            
            	var	oPopup = window.createPopup();
            	var el;
            		oPopup.document.write(html);
            				oPopup.document.body.style.overflow='hidden'
            				oPopup.document.body.style.border='none'
            }
            
            function dopopup(obj) {
                var lefter2 = event.offsetY+0;
                var topper2 = event.offsetX+15;
                el=obj;
                if(isie) {
            		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>
            </body>
            </html>
            I wouldn't mind having those images, just for kicks!

            Edit: Just noticed that simply moving:
            Code:
            oPopup.document.body.innerHTML = html;
            out of the function and below this line:
            Code:
            	var el;
            does a world of good and avoids a lot of the above code.
            Last edited by jscheuer1; Aug 3, 2005, 01:34 PM.
            - John

            Comment


            • #7
              jscheuer1,

              Excellent work!!

              Here are the images etc. the cut, copy and paste were captured from word. I've tried to make them transparent and reduced them to 12x12, if you have better images as well as any ChangeCase, undo and redo images I'll happily take them.

              Note It's still a work in progress so the formatting etc. isn't quite right
              It's a demo/idea for a project I'm about to start on.

              Cheers Al
              Attached Files

              Comment


              • #8
                Thanks Al,

                Sooner or later I'm going to put up a 'Javascript Jungle' sight with scripts I've written and modded from this and other forums. I already have a live repository but, variations of this script are not on it. Would it be OK with you to add a version of it? If so, how would you like to be credited (email me if you don't want to publicize your info in these forums)? Anyways, I've come up with a version that changes case and adds proper case only to the selected text and also has added code to compensate for the fact that menu items no longer lose their highlight onclick due to the popup menu only being written once. It is a little finicky as to where you can put the mouse cursor after highlighting as you right click to change the case/proper case selected text. Also I'm not real pleased with the proper case routine. It doesn't always perform as expected. I'm eventually going to take a crack at fixing that and/or changing it to an initial caps rather than proper case option. Another tweak to the code may be that, since we are only writing to the popup once, writing a script to it to perform the various mouse events on it.

                Here's my current working version:
                Code:
                <html>
                <head>
                <script type="text/javascript">
                function ProperCase(){
                	/*
                	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
                	*/
                	
                	doCopy();
                	var STRING=copiedtext
                	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
                	
                	window.clipboardData.setData("Text", strReturn_Value)
                	document.execCommand("Paste")
                	//return ;
                } //End Function
                
                function LowerCase(){
                	doCopy();
                	var STRING=copiedtext
                	var strReturn_Value = "";
                	var iTemp = STRING.length;
                	if(iTemp==0){
                		return false;
                	}
                
                	strReturn_Value = STRING.toLowerCase();
                
                	window.clipboardData.setData("Text", strReturn_Value)
                	document.execCommand("Paste")
                //	return strReturn_Value;
                } //End Function
                
                function UpperCase(){
                	doCopy();
                	var STRING=copiedtext
                	var strReturn_Value = "";
                	var iTemp = STRING.length;
                	if(iTemp==0){
                		return false;
                	}
                
                	strReturn_Value = STRING.toUpperCase();
                
                	window.clipboardData.setData("Text", strReturn_Value)
                	document.execCommand("Paste")
                //	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(theField) {
                
                	if (document.all){
                		theField.focus()
                		document.execCommand("Undo")
                	}
                }
                
                function doRedo(theField) {
                
                	if (document.all){
                		theField.focus()
                		document.execCommand("Redo")
                	}
                }
                </script>
                
                </head>
                <body topmargin="50" leftmargin="20">
                
                <!--Begin Context Menu -->
                <script type="text/javascript">
                /*
                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.ProperCase();document.all.i0.style.background=\'#CCCCCC\';document.all.i0.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();">&nbsp;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.UpperCase();document.all.i1.style.background=\'#CCCCCC\';document.all.i1.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();">&nbsp;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.LowerCase();document.all.i2.style.background=\'#CCCCCC\';document.all.i2.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();">&nbsp;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);document.all.i3.style.background=\'#CCCCCC\';document.all.i3.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;<img src="images/cut.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;Cut&nbsp;&nbsp;</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);document.all.i4.style.background=\'#CCCCCC\';document.all.i4.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;<img src="images/copy.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;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);document.all.i5.style.background=\'#CCCCCC\';document.all.i5.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;<img src="images/paste.gif" width="12" height="12" border="0" hspace="0" vspace="0" align="absmiddle">&nbsp;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);document.all.i6.style.background=\'#CCCCCC\';document.all.i6.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;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.el);document.all.i7.style.background=\'#CCCCCC\';document.all.i7.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;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.el);document.all.i8.style.background=\'#CCCCCC\';document.all.i8.style.border=\'1pt solid #CCCCCC\'; parent.oPopup.hide();"><table width="100%"><tr><td>&nbsp;Redo</td><td>Ctrl+Y</td></tr></table></td></tr>';
                
                	html+='</table>';
                
                	var	oPopup = window.createPopup();
                	var el;
                		oPopup.document.body.innerHTML = html;
                }
                
                function dopopup(obj) {
                    var lefter2 = event.offsetY+0;
                    var topper2 = event.offsetX+15;
                    el=obj;
                    if(isie) {
                
                		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>
                </body>
                </html>
                I'll let you know about the images.
                - John
                - John

                Comment


                • #9
                  jscheuer1,

                  I've no problem with you using the script I put it together using scripts gleaned off dynamic drive and the rest of the web then tweaked them to suit me as well as additions by good folk such as yourself from the forum.

                  I don't mind if you don't credit me, but if you want to, you can use my hotmail address [email protected].
                  The ProperCase function was taken from - http://www.apriori-it.co.uk/PCase.asp

                  RE the ProperCase function; I want to use it to proper case names in particular, what problems have you noticed with it?

                  I'm liking your new version with the change selected text!! I had done one myself or at least put one together but have a couple of small bugs with it. The main one being when you undo (Ctrl+Z) twice it sticks in "#$%^%$#" anyway it's another way of doing it. Check it out. Easiest way is to copy the code below to - www.w3schools.com/html/tryit.asp that way you don't have to save it.

                  Code:
                  <html>
                  <head>
                  <script type="text/javascript">
                  <!-- // Begin Hide
                  function getSelection(ta)
                    { var bits = [ta.value,'','',''];
                      if(document.selection)
                        { var vs = '#$%^%$#';
                          var tr=document.selection.createRange()
                          if(tr.parentElement()!=ta) return null;
                          bits[2] = tr.text;
                          tr.text = vs;
                          fb = ta.value.split(vs);
                          tr.moveStart('character',-vs.length);
                          tr.text = bits[2];
                          bits[1] = fb[0];
                          bits[3] = fb[1];
                        }
                      else
                        { if(ta.selectionStart == ta.selectionEnd) return null;
                          bits=(new RegExp('([\x00-\xff]{'+ta.selectionStart+'})([\x00-\xff]{'+(ta.selectionEnd - ta.selectionStart)+'})([\x00-\xff]*)')).exec(ta.value);
                        }
                       return bits;
                    }
                  
                   function UpperCase(el){
                   	var bits = getSelection(el);
                   	if (bits) {
                  		var iTemp = bits[2].length;
                  		if(iTemp==0){
                  			return false;
                  		}
                  		el.value = bits[1] + bits[2].toUpperCase() + bits[3];
                  		return true;
                  	}
                  	else
                  	{
                  		return false;
                  	}
                   } //End Function
                  
                  
                  // End Hide -->
                  </script>
                  <style type="text/css">
                  </style>
                  </head>
                  
                  <body>
                  <p>Select text in the textarea. Click the button</p>
                  <form name="myfrm" id="myfrm">
                  <button onclick="UpperCase(document.myfrm.text);"><u>UpperCase</u></button>
                  <br />
                  <textarea id="text" rows="20" cols="80">
                  A Sho in the Kalahari desert encounters technology for the first time--in the shape of a Coke bottle. He takes it back to his people, and they use it for many tasks. The people start to fight over it, so he decides to return it to the God--where he thinks it came from.</textarea>
                  <br />
                  <br />
                  <button onclick="UpperCase(document.myfrm.txtTest);"><u>UpperCase</u></button>
                  <br />
                  <input type="text" name="txtTest" id="txtTest" value="hello" />
                  <br />
                  <p>when do undo x 2 get '#$%^%$#' which is no good!! <br />plus sometimes selects all after calling function </p>
                  </form>
                  </body>
                  </html>

                  Note: There were a couple of bugs in your script extra spaces after the escape char e.g. border=\ '1pt which might have been added in by CodingForum when you uploaded the post not sure?

                  I'll be interested in any new versions that you come up with so please keep me posted

                  Cheers Al
                  Last edited by Running Bear; Aug 5, 2005, 11:31 AM.

                  Comment


                  • #10
                    Have noticed a bug:

                    If you right click and choose any of the change case functions without selecting anything it bombs out!!

                    Argh! I see now that if nothing is selected it converts and inserts whatever is on the clipboard!!

                    Code:
                    o'connell was here [B]<A HREF="..\MENU.HTML">HERE</A>[/B]wasn't he?
                    Cheers Al

                    Comment


                    • #11
                      Have found this thread which has another way of handling getting and replacing selected text, haven't tried it yet will try and get something working later

                      http://www.ms-inc.net/ViewThread.aspx?ThreadID=169

                      Edit:
                      This is what I have so far but am getting an object error on line 64 (actually errors on line 65) which I can't understand
                      Code:
                      <html>
                      <head>
                      <script type="text/javascript">
                      <!-- // Begin Hide
                      function GetSelectedText( elementID ){
                      	var obj = document.getElementById( elementID );
                      	if( !obj ) {
                      		throw "Element " + elementID + " not found!";
                      	}
                      	// Netscape, Mozilla, Firefox
                      	if( typeof(obj.selectionStart) != "undefined" ){
                      		obj.focus();
                      		var start_selection = obj.selectionStart;
                      		var end_selection = obj.selectionEnd;
                      		if (end_selection < start_selection){
                      			var temp = end_selection;
                      			end_selection = start_selection;
                      			start_selection = temp;
                      		}
                      		return (obj.value).substring(start_selection, end_selection);
                      	}
                      	// Internet Explorer
                      	if( obj.createTextRange ){
                      		obj.focus( obj.caretPos );
                      		obj.caretPos = document.selection.createRange().duplicate();
                      		return obj.caretPos.text;
                      	}
                      }
                      
                      function SetSelectedText( elementID, text ){
                      	var obj = document.getElementById( elementID );
                      	if( !obj ) {
                      		throw "Element " + elementID + " not found!";
                      	}
                      	// Netscape, Mozilla, Firefox
                      	if( typeof(obj.selectionStart) != "undefined" ){
                      		obj.focus();
                      		var start_selection = obj.selectionStart;
                      		var end_selection = obj.selectionEnd;
                      		if (end_selection < start_selection){
                      			var temp = end_selection;
                      			end_selection = start_selection;
                      			start_selection = temp;
                      		}
                      		// Sad, but true: You actually have to replace *all* of the text in
                      		// the text input to replace the selection in Mozilla browsers!
                      		var startText = (obj.value).substring(0, start_selection);
                      		var endText = (obj.value).substring(end_selection, obj.textLength);
                      		obj.value = startText + text + endText;
                      		obj.selectionStart = start_selection;
                      		obj.selectionEnd = start_selection + text.length;
                      	}
                      	// Internet Explorer
                      	if( obj.createTextRange ){
                      		obj.focus( obj.caretPos );
                      		obj.caretPos = document.selection.createRange().duplicate();
                      		obj.caretPos.text = text;
                      		obj.caretPos.moveStart( "character", text.length * -1 );
                      		obj.caretPos.select();
                      	}
                      	obj.focus();
                      }
                      
                      function UpperCase(elementID){
                       	var selTxt = GetSelectedText(elementID);
                       	if (selTxt) {
                      		var iTemp = selTxt.length;
                      		if(iTemp==0){
                      			return false;
                      		}
                      		selTxt=selTxt.toUpperCase();
                      		SetSelectedText(elementID,selTxt);
                      		return true;
                      	}
                      	else
                      	{
                      		return false;
                      	}
                       } //End Function
                      
                      
                      // End Hide -->
                      </script>
                      <style type="text/css">
                      </style>
                      </head>
                      
                      <body>
                      <p>Select text in the textarea. Click the button</p>
                      <form name="myfrm" id="myfrm">
                      <button onclick="UpperCase('ta1');"><u>UpperCase</u></button>
                      <br />
                      <textarea name="ta1" id="ta1" rows="20" cols="80">
                      A Sho in the Kalahari desert encounters technology for the first time--in the shape of a Coke bottle. He takes it back to his people, and they use it for many tasks. The people start to fight over it, so he decides to return it to the God--where he thinks it came from.</textarea>
                      <br />
                      <br />
                      <button onclick="UpperCase('txtTest');"><u>UpperCase</u></button>
                      <br />
                      <input type="text" name="txtTest" id="txtTest" value="hello" />
                      </form>
                      </body>
                      </html>


                      Edit:
                      Fixed error on line 64 (65) as described above, was calling the function using "getSelectedText" should have been and now is - "GetSelectedText" - amateur!!
                      Last edited by Running Bear; Aug 9, 2005, 07:25 AM. Reason: Insert Code snippet, fix bug line 64 (actually 65)

                      Comment


                      • #12
                        That's a lot to comment on. First:
                        Originally posted by Al
                        RE the ProperCase function; I want to use it to proper case names in particular, what problems have you noticed with it?
                        I've already fixed this in a version I have here but, what it was doing was ignoring the first character on a new line if multiple lines were selected. The fix:
                        Code:
                        		if(iChar == 32 || iChar == 45 || iChar == 46 || iChar == 13 || iChar == 10){
                        			UcaseNext = true;
                        was just adding in the new line chars to the UcaseNext test.

                        As for it and the other case changers bombing on no select. I've been thinking about that. One idea is to empty the clipboard at some point if some condition is met. Like when they click a case changer, record the clipboard contents to a variable, then perform a copy, check clip contents against previous variable, if equal, return; but, that will omit case changes in certain situations. Must find a way to test if any text is selected.
                        Originally posted by Al
                        when you undo (Ctrl+Z) twice it sticks in "#$%^%$#"
                        Unable to duplicate in my current version, either I misunderstand the problem or it is fixed already. My current version is not the one I last posted. I've included a 'delete' option, moved mouseover/out functions off of the popup (which allowed me to dispense with individual id's for each option), as well as compacted the code in other ways (using the style section instead of inline style for some things) and added some formatting to the popup that eliminates the need for so many &nbsp; chars while getting things to really line up. I'll see if I can iron out that case bug (I had noticed it) and post it all later. I've copied the link to the cross browser routines, that will be a major rewrite but, I know in advance that Mozilla can disable alternate context menus. So, that would best be done as a drop down style menu or simple on page menu.
                        Originally posted by Al
                        Note: There were a couple of bugs in your script extra spaces after the escape char e.g. border=\ '1pt which might have been added in by CodingForum when you uploaded the post not sure?
                        Most likely CF added those in as they are not in my original code. I just noticed the other day that the CF editor or one on one of the other forums was doing that on a short snippet. I used the color text option to create a work around. I wonder why the editor would do that to begin with?
                        - John

                        Comment


                        • #13
                          undo (Ctrl+Z) twice it sticks in "#$%^%$#"
                          This is a bug in my version of "change selection only" NOT yours, I just added it in so you could see an alternative way of getting the selected text without using the clipboard.

                          Anyway I'm looking forward to seeing your new version...

                          Comment


                          • #14
                            I've fixed the 'case' bug by saving the clipboard contents, emptying it, performing the case function, then restoring the clipboard contents. Because of the bug in the editor that you mentioned, I'm attaching the new version instead.
                            Attached Files
                            - John

                            Comment


                            • #15
                              Looking Good!!

                              I'm very interested in a x-browser version of this, but don't know whether it's possible

                              Comment

                              Working...
                              X