Jump to content

Browser compatibility for my script


wagga2650

Recommended Posts

I have this javascript that when you  press a button it oauto selects the data in the textarea and copies it so all you need to do is paste it back into another application.

It works fine in IE but in other browsers it only highlights but not copies it to the clipboard, can someone take a look and advise where I have gone wrong please.

 

here is the code

 

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function copyit(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")
}
//  End -->
</script>

</head>

<BODY>

<form name="it">
<div align="center">
<input onclick="copyit('it.select1')" type="button" value="Press to Copy the Text" name="cpy">
<p>
<textarea name="select1" rows="3" cols="25">
If this is highlighted, then it has been copied.
</textarea>
</div>
</form>

<!-- Script Size:  1.21 KB -->

</body>

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.