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
https://forums.phpfreaks.com/topic/268933-copy-to-clipboard/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.