> [[copytoClipboard]]
> <html><nowiki><a href="javascript:;" title="$2"
> onclick="
> var holdtext = document.createElement('TEXTAREA');
> holdtext.innerText='$1';
> Copied = holdtext.createTextRange();
> Copied.execCommand('Copy');
> return false;
> ">$1</a></html>
...
If you are certain to be using IE7 or above, you can simplify the
onclick handler to just:
window.clipboardData.setData('text','$1');
If you want to be cross-browser compatible, then take a look at the
"copy()" function I wrote for
http://www.TiddlyTools.com/#SaveToClipboard
---------------------
function copy(out) {
if(window.Components) { // FIREFOX
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var id='@mozilla.org/widget/clipboardhelper;1';
var
clip=Components.classes[id].getService(Components.interfaces.nsIClipboardHelper);
clip.copyString(out);
} else if(window.clipboardData) { // IE
window.clipboardData.setData('text',out);
} else if(document.execCommand) { // CHROME, SAFARI, IE6
var ta=document.createElement('textarea');
ta.style.position='absolute';
ta.style.left='-100%';
document.body.appendChild(ta);
ta.value=out; ta.select();
document.execCommand('Copy',false,null);
document.body.removeChild(ta);
} else throw('cannot access clipboard');
}
---------------------
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
----------
Was this answer useful? If so, please help support TiddlyTools:
TiddlyTools direct contributions: (paypal)
http://www.TiddlyTools.com/#Donate
UnaMesa tax-deductible contributions:
http://about.unamesa.org/Participate (paypal)
TiddlyWiki consulting:
http://www.TiddlyTools.com/#ELSDesignStudios
http://www.TiddlyTools.com/#Contact
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en.