Tekdot
October 18, 2005, 2:59am
1
Hello,
First off, I’m a complete javascript newb. Heres my problem, Im trying to copy text box to the clipboard and heres what i have so far
in the header
<SCRIPT LANGUAGE="JavaScript">
function ClipBoard()
{
alert("copied");
window.clipboardData.setData("Text",document.links.txtbox1);
}
</SCRIPT>
in the body
<form id=links>
<input type="text" id="txtbox1" class="formtext" onClick=\\'highlight(this);\\' style="width: 400px" size="70" value="dummy text" /><br />
<BUTTON onClick="ClipBoard();">Copy</BUTTON>
</form>
gph
October 18, 2005, 4:12am
2
Lots of little things, see red type
<script [COLOR=Red]type="text/javascript"[/COLOR]>
function ClipBoard()
{
alert("copied");
window.clipboardData.setData("Text",document.links.txtbox1[COLOR=Red].value[/COLOR]);
}
</script>
<form [COLOR=Red]name[/COLOR]=[COLOR=Red]"[/COLOR]links[COLOR=Red]"[/COLOR]>
<input type="text" [COLOR=Red]name[/COLOR]="txtbox1" class="formtext" on[COLOR=Red]c[/COLOR]lick=[COLOR=Red]"[/COLOR]highlight(this)[COLOR=Red]"[/COLOR] style="width: 400px" size="70" value="dummy text" /><br />
<BUTTON on[COLOR=Red]c[/COLOR]lick="ClipBoard()">Copy</BUTTON>
</form>
function ClipBoard()
{
if (window.clipboardData) {
alert("copied");
window.clipboardData.setData("Text",document.links.txtbox1.value);
}
}
That way the alert wont come up telling people it is copied when it isn’t where the browser is not Internet Explorer (only IE allows the page to access the clipboard).