/    Sign up×
Community /Pin to ProfileBookmark

clipboard help

Trying to get this to work on both IE and Firefox.
I found this script by searching

[code]
<html>

<script>
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);

}

return false;
}
//–>
</script>
<body>
<form name=”testform”>
<textarea name=”testsquare”>

</textarea>
<br>
<input type=”button” onclick=”return copy_clip(document.forms[0].testsquare.value)” value=”Copy to Clipboard”>
</form>

</body>
</html>
[/code]

Which works great. Now im trying to adapt this to what i want it to copy.
which is this,

[code]
Reason for requesting replacement:<?php echo $rfr;?><br>
Make/Model Number:<?php echo $mk; ?> , <?php echo $md; ?><br>
WDS: <?php echo $wd; ?><br>
Serial Number: <?php echo $sn; ?><br>
MAC Address: <?php echo $ma; ?><br>
IP Address: <?php echo $ip; ?><br>
Property ID: <?php echo $pp; ?><br>
Property Contact Name/Title:<?php echo $ct; ?><br>
Shipping Severity: <?php echo $sp; ?><br>
Ticket #: <?php echo $tt; ?><br>
Comments: <?php echo $cm; ?><br>
[/code]

Now that is fed from a form. How would i go about adapting all this. I have tried just pasting this into the text area but that didnt work. I have tried adding a table and adding it in there but then the javascript errors out.
any ideas?
Thanks for all the help!!!!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinNov 25.2006 — Oh, I though this was going to be great, I've been using an IE only script for a long time and thought maybe someone finally worked something out to work in Firefox too.

However, are you sure you want the client to get a security alert every time they they try to "copy to clipboard?"
Copy linkTweet thisAlerts:
@prophitauthorNov 25.2006 — Since this is for an intranet site sure.. If it was for the net then no..
×

Success!

Help @prophit spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...