| | |
Copy text to clipboard
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Solved Threads: 0
Hi there all
I am in the process of developing a knowledgebase..
I have some cool click and copy script but it doesnt allow me to format the text that is copied so that I can copy an already fromatted email..
for example:
Hi,
thank you for contacting us, blablablablablablablablablablabla
blablablablablablablablablablablablablablablablabla
Kind regards
blabla.
here is the jscript I have:
[html]
<script language="javascript" type="text/javascript">
<!--
function copy_clip(meintext)
{
if (window.clipboardData)
{
window.clipboardData.setData("Text", meintext);
}
else if (window.netscape)
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip = Components.classes['@mozilla.org/widget/clipboard;1']
.createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
var trans = Components.classes['@mozilla.org/widget/transferable;1']
.createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
trans.addDataFlavor('text/unicode');
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
var copytext=meintext;
str.data=copytext;
trans.setTransferData("text/unicode",str,copytext.length*2);
var clipid=Components.interfaces.nsIClipboard;
if (!clip) return false;
clip.setData(trans,null,clipid.kGlobalClipboard);
}
alert("The following text has been copied:\n\n" + meintext);
return false;
}
//-->
</script>
<p><span onclick='return copy_clip("this text will be copied to clipboard'>
when you click on this text, the above is copied.(but you cant see it untill you paste it.
</span> </p>
[/html]
here is my problem.
I cant format any thing in this area
<p><span onclick='return copy_clip("this text will be copied to clipboard'>
I get that jscript error if i try...
I want to for example, do something like this:
<p><span onclick='return copy_clip("hi there,
<p>thank you for contacting us etc</p>")'>
so that when pasted you can have a nicely formatted email/...
Please HELP
thanks!!
I am in the process of developing a knowledgebase..
I have some cool click and copy script but it doesnt allow me to format the text that is copied so that I can copy an already fromatted email..
for example:
Hi,
thank you for contacting us, blablablablablablablablablablabla
blablablablablablablablablablablablablablablablabla
Kind regards
blabla.
here is the jscript I have:
[html]
<script language="javascript" type="text/javascript">
<!--
function copy_clip(meintext)
{
if (window.clipboardData)
{
window.clipboardData.setData("Text", meintext);
}
else if (window.netscape)
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip = Components.classes['@mozilla.org/widget/clipboard;1']
.createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
var trans = Components.classes['@mozilla.org/widget/transferable;1']
.createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
trans.addDataFlavor('text/unicode');
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
var copytext=meintext;
str.data=copytext;
trans.setTransferData("text/unicode",str,copytext.length*2);
var clipid=Components.interfaces.nsIClipboard;
if (!clip) return false;
clip.setData(trans,null,clipid.kGlobalClipboard);
}
alert("The following text has been copied:\n\n" + meintext);
return false;
}
//-->
</script>
<p><span onclick='return copy_clip("this text will be copied to clipboard'>
when you click on this text, the above is copied.(but you cant see it untill you paste it.
</span> </p>
[/html]
here is my problem.
I cant format any thing in this area
<p><span onclick='return copy_clip("this text will be copied to clipboard'>
I get that jscript error if i try...
I want to for example, do something like this:
<p><span onclick='return copy_clip("hi there,
<p>thank you for contacting us etc</p>")'>
so that when pasted you can have a nicely formatted email/...
Please HELP
thanks!!
Last edited by tgreer; Aug 29th, 2006 at 10:44 am. Reason: User ignored rule regarding code tags.
![]() |
Similar Threads
- Can't read what I am posting (DaniWeb Community Feedback)
- Get the text with mouse hover (JavaScript / DHTML / AJAX)
- Formatting clipboard text for spreadsheets (Visual Basic 4 / 5 / 6)
- clipboard in console (C++)
- Please Help, Junk on machine (Windows NT / 2000 / XP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: close event for firefox
- Next Thread: how to change the the value of src in <embed> using javascript
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array beta box browser captchaformproblem cart checkbox child close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype redirect runtime safari scale scriptlets scroll search security select shopping size software unicode w3c web window windowofwords wysiwyg \n






