?
Solved

cut copy paste

Posted on 2004-10-06
5
Medium Priority
?
742 Views
Last Modified: 2008-02-01
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
Comment
Question by:das165227
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:riyasjef
ID: 12240649
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
 
LVL 9

Accepted Solution

by:
riyasjef earned 1500 total points
ID: 12240673
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
 

Author Comment

by:das165227
ID: 12247969
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
 

Author Comment

by:das165227
ID: 12310177
sorry i just haven't had time to address this thing since i've been working on something else
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question