Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:38

Copy Function Does Not Work With Right Click Menu


Poster: pentace
Dated: Friday March 16 2007 - 21:37:43 GMT

I have this code that basically duplicates the right click and copy feature or ctrl +c and it works fine if it is anything on the page calling the function, but if i use a menu like the right click menu it calls the function but nothing copies... can anyone help?


Code:
<script>
function Dupme() {
     // Get the selected Html source of the window object
     // where the context menu item was executed
     var selectedHtml=(document.selection.createRange()).htmlText;
     // Set the clipboard with selected HTML, if there is any
     if(selectedHtml!= "")
         window.clipboardData.setData("Text",selectedHtml);}


</script>
<input type=button value="Copy Selected Text" onclick=Dupme()>
test text to copy


This code works fine but if i take out the button and use a menu with this... nothing copies

Code:
aI("separatorsize=1;text=Copy Selected;url=javascript:Dupme();");



http://www.milonic.com/menusample27.php Here is the menu im trying to add it into


Poster: Ruth
Dated: Saturday March 17 2007 - 1:07:25 GMT

Hi,

The problem is that you must set that aI string to type=html;

Code:
aI("separatorsize=1;text=Copy Selected;url=javascript:Dupme();type=html;");


You do know that this isn't going to work in other than IE? For example, in FF [an older version] it does copy to clipboard but it copies the aI string, not any text you highlight. I believe that's going to be an issue, since the copy to clipboard I think is IE only. Here's a post which kind of say it's not going to happen, since in reality the right click and get a context menu with copy on it is not part of the web page but part of the operating system, and for security reasons FF and Moz don't allow that kind of access.

http://www.milonic.com/forum/viewtopic. ... 0065#30065

Info on allowing access for FF which I found

http://kb.mozillazine.org/Granting_Java ... _clipboard

and one site which says they have a function that works across the browsers, something about having to sign the js. The page is hard to read since it is dark and seems to have dark green text in parts of the 'code' examples, but I highlighted the page which makes it look white and could read it :) I thought it might give you some help if you know anything about js, which I don't.

http://www.krikkit.net/howto_javascript ... board.html

Hope this helps

Ruth

Thanks


Poster: pentace
Dated: Saturday March 17 2007 - 1:12:15 GMT

Thanks... it worked great.. I cant beleive it was something that simple.