[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

cut copy paste

Posted on 2004-10-06
5
Medium Priority
?
744 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

649 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