Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 747
  • Last Modified:

cut copy paste

oh and first thing: only needs to work in ie

hey a while back i was working on something for my web word processor. i thought i'd give it another go.  

i got the context menu to work but i was never able to get cut copy and paste to work in it.

i was just losing the ranges and/or selections.  i think what is going to have to be done is everytime a selection is made it remembers it right here. if another selection is made then it just overwrites that variable.  i don't know. ranges and selections aren't my strong point.

heres some code.  

my context menu: and iframe that goes behind it

<IFRAME id="ContextIFrame" style="Z-INDEX: 106; LEFT: 312px; VISIBILITY: hidden; WIDTH: 60px; POSITION: absolute; TOP: 152px; HEIGHT: 132px">

<DIV class="Context" id="ContextDiv" style="Z-INDEX: 107; LEFT: 392px; VISIBILITY: hidden; WIDTH: 60px; POSITION: absolute; TOP: 152px; HEIGHT: 132px">
                        <TABLE style="FONT-SIZE: 8pt; FONT-FAMILY: Tahoma">
                              <TR>
                                    <td onmouseover="SetRollOverClass(this,'ContextTDMouseOver');" onclick="WP_SelectAll('WordProcessor1');"
                                          onmouseout="SetRollOutClass(this,'ContextTDMouseOut');">Select All</td>
                              </TR>
                              </TR>
                              <tr>
                                    <TD style="HEIGHT: 1px">
                                          <hr>
                                    </TD>
                              </tr>
                              <TR>
                                    <TD onmouseover="SetRollOverClass(this,'ContextTDMouseOver');" onclick="WP_Save('WordProcessor1');"
                                          onmouseout="SetRollOutClass(this,'ContextTDMouseOut');">Save</TD>
                              </TR>
                              <tr>
                                    <td onmouseover="SetRollOverClass(this,'ContextTDMouseOver');" onclick="WP_SaveAs('WordProcessor1');"
                                          onmouseout="SetRollOutClass(this,'ContextTDMouseOut');">Save As</td>
                              </tr>
                              </TR>
                              <tr>
                                    <TD>
                                          <hr>
                                    </TD>
                              </tr>
                              <tr>
                                    <TD onmouseover="SetRollOverClass(this,'ContextTDMouseOver');" onclick="WP_Print('WordProcessor1')"
                                          onmouseout="SetRollOutClass(this,'ContextTDMouseOut');">Print</TD>
                              </tr>
                              <TR>
                                    <TD onmouseover="SetRollOverClass(this,'ContextTDMouseOver');" onclick="WP_SpellChecker('WordProcessor1');"
                                          onmouseout="SetRollOutClass(this,'ContextTDMouseOut');">SpellCheck</TD>
                              </TR>
                        </TABLE>
                  </DIV>

javascript that shows and hides the context menu

function ShowMyContextMenu(div,iframe) {      
      var contextMenu= document.getElementById(div);
      var contextIFrame= document.getElementById(iframe);      
      var x;
      var y;
      if(event === null) {
            x= editor.event.clientX + contextOffsetX;
            y= editor.event.clientY + contextOffsetY;            
      } // end if
      else {
            x= event.clientX;
            y= event.clientY;
      } // end else            
      contextIFrame.style.left= x;
      contextIFrame.style.top= y;
      contextMenu.style.left= x;
      contextMenu.style.top= y;
      contextIFrame.style.visibility= "visible";
      contextMenu.style.visibility= "visible";            
} // end function

function HideContextMenu() {
      var context= document.getElementById("ContextDiv");
      if(context === null) {
            return;
      } // end if
      var contextFrame= document.getElementById("ContextIFrame");
      if(context.style.visibility == "visible") {
            context.style.visibility= "hidden";
            contextFrame.style.visibility= "hidden";                              
      } // end if
} // end function

my cut, copy, and paste functions just use the microsoft execCommands
0
das165227
Asked:
das165227
  • 2
  • 2
1 Solution
 
riyasjefCommented:
Did u try this?
       
              function init()   //ONLOAD
             {
                  var obj=document.getElementById("ContextIFrame");
                  obj.document.designMode='On';
       
                 }

       function editor_cut()
       {
                 document.getElementById("ContextIFrame").focus();
          document.getElementById("ContextIFrame").document.execCommand('cut','',null);
       }

       function editor_copy()
       {
                document.getElementById("ContextIFrame").focus();
          document.getElementById("ContextIFrame").document.execCommand('cut','',null);
       }

Riyasjef
0
 
riyasjefCommented:
Sorry

function editor_copy()
      {
         document.getElementById("ContextIFrame").focus();
         document.getElementById("ContextIFrame").document.execCommand('copy','',null);
      }

function editor_paste()
      {
         document.getElementById("ContextIFrame").focus();
         document.getElementById("ContextIFrame").document.execCommand('paste','',null);
      }

0
 
das165227Author Commented:
i'm not sure that'll work.  i'll try it after i get done with the stuff i'm doing now but it looks like that code is going to end up copying whats in the context menu.  the main issue is keeping what is selected in the iframe selected while my context menu is open.  that oughta do it
0
 
das165227Author Commented:
sorry i just haven't had time to address this thing since i've been working on something else
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now