Jump to content

Copy To Clipboard


Pegasus3245

Recommended Posts

Hi Everyone,

I have a text box, with an address which visitors need to copy into another application. I have the text box, this has the text inside. All I need now is a button that says 'copy' and when you click it, wola! However, the real world hasnt worked this way for me :confused: .

 

The code I have is;

<script type="text/javascript">
function ClipBoard()
{
if (window.clipboardData) {
  alert("copied");
  window.clipboardData.setData("Text",document.form1.name.value);
}
}
</script>
<form name="form1" method="post" action="">
<input name="name" type="text" class="inputtext" onclick="highlight(this)" id="name" value="<?php echo "$contents";?>">
<BUTTON onclick="ClipBoard()">Copy</BUTTON> 
</form>

 

I dont understand why this wont work...

 

Any help would be greatly apreciated.

 

Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.