Page 1 of 1

Copy selected text to clipboard

PostPosted: Fri Dec 03, 2010 2:05 am
by smartmedia
Hi..

I want when i select some text in a WebBroswer running in NB to press a button and that selected text, to be copied into clipboard. I have found this, but i don't have knowledge to modify it and make it work for NB.
http://javascript.internet.com/page-det ... -text.html

Can someone help...???
Thanks

Re: Copy selected text to clipboard

PostPosted: Fri Dec 03, 2010 3:32 am
by Tony Kroos
smartmedia wrote:Thanks


Thanks? ok, give it to me! ))

Create button with BrowserExecScript command and add here some js code:

Code: Select all
var selectedText = document.selection;
if (selectedText.type == 'Text')
{
var newRange = selectedText.createRange();
newRange.execCommand("Copy");
}


Select text in browser, then press this button. Text (only text) will be copied to clipboard ))) but why do you need this, you can copy/paste text with "mouse right-click" menu...

Maybe...

PostPosted: Fri Dec 03, 2010 9:36 am
by virger
Try this....
1.Create this "HTML"
------------------------
<html>
<head>
<script language="JavaScript">
function marco(){
var rng = document.selection.createRange().text;
window.external.nbSetVar( "[clipboard]", rng );
}
</script>
</head>
<body onmouseup="marco()" >
DESDE COSTA RICA EN

AMERICA CENTRAL

OXIGENANDO AL MUNDO Y MAS

</body>
</html>

2.Run
3.Marca any text
4.[ClipBoard]...has your selection.

PURA VIDA
SOMOS ASI
DESDE COSTA RICA

PostPosted: Fri Dec 03, 2010 11:22 am
by smartmedia
Hi..

Thanks both, Tony's method worked fine with me... Now i have one other problem similar to that. I want to copy the link of an image but when i hit mouse right click i don't see any menu to selected. In Firefox there is but in Web object in NB there isn't. Any ideas how to accomplish that...???

Please explain.

PostPosted: Fri Dec 03, 2010 6:54 pm
by virger
This is a tag type image <img ...>
or type in <a href image ....> ?

DESDE COSTA RICA
QUE ESTEN PURA VIDA
EN ESTA NAVIDAD
---------------------
FROM COSTA RICA
YOU ARE PURE LIFE
THIS CHRISTMAS