HighDots Forums  

Autocopy sul tag PRE

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Autocopy sul tag PRE in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gialloporpora
 
Posts: n/a

Default Autocopy sul tag PRE - 05-06-2008 , 04:15 PM






Salve a tutti,

io non sono espertissimo di Javascript e quindi volevo sapere da
qualcuno più esperto se è possibile modificare lo script trovato qui:
http://www.jeffothy.com/weblog/clipboard-copy
e che inserisco a fine post per fare in modo che funzioni su ogni
elemento HTML.

Attualmente lo script funziona solo sui campi di INPUT, io vorrei
attivare il copia incolla all'interno del tag PRE.

Se non è possibile, fa nulla :-)


function copyToClipboard(inElement) {
var clipboardswfpath="_clipboard.swf";
if (inElement.createTextRange) {
var range = inElement.createTextRange();
if (range && BodyLoaded==1)
range.execCommand('Copy');
} else {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '<embed src="'+clipboardswfpath+'"
FlashVars="clipboard='+encodeURIComponent(inElemen t.value)+'" width="0"
height="0"></embed>';
document.getElementById(flashcopier).innerHTML = divinfo;
}
}



--
*Uno sguardo ai “SEgnalibri Smart” e alle “Places query”* -
http://tinyurl.com/64bjx8
*Featured Firefox Extension: OPIE Exports Extension Preferences for
Quick Firefox Setup* - http://tinyurl.com/6go2am
* FAQ* di /it-alt.comp.software.mozilla/: http://dwarfurl.com/f6c23

Reply With Quote
  #2  
Old   
gialloporpora
 
Posts: n/a

Default Re: Autocopy sul tag PRE - 05-07-2008 , 05:30 PM






Risposta al messaggio di gialloporpora :

Quote:
Salve a tutti,

io non sono espertissimo di Javascript e quindi volevo sapere da
qualcuno più esperto se è possibile modificare lo script trovato qui:
http://www.jeffothy.com/weblog/clipboard-copy
e che inserisco a fine post per fare in modo che funzioni su ogni
elemento HTML.

Attualmente lo script funziona solo sui campi di INPUT, io vorrei
attivare il copia incolla all'interno del tag PRE.

Se non è possibile, fa nulla :-)

Ok, ho risolto da solo :-)
Basta selezionare il contenuto del tag pre con:

var range = document.createRange();range.selectNodeContents(th is);

Ciao


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.