Source language: Translate to:

Copy selected text to clipboard

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Copy selected text to clipboard

Postby smartmedia » Fri Dec 03, 2010 2:05 am

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
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Re: Copy selected text to clipboard

Postby Tony Kroos » Fri Dec 03, 2010 3:32 am

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...
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Maybe...

Postby virger » Fri Dec 03, 2010 9:36 am

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
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Postby smartmedia » Fri Dec 03, 2010 11:22 am

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...???
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Please explain.

Postby virger » Fri Dec 03, 2010 6:54 pm

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
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests