Guest ethicalhacker Posted March 22, 2007 Share Posted March 22, 2007 I used the following code to select text in the textarea and it works great in both ie and firefox <INPUT TYPE="button" value= "Select Text" onClick="document.Add.write.select()"> But I used the following code <INPUT TYPE="button" value= "Copy" onclick="document.execCommand('Copy')"> for copying and it only works in ie (internet explorer ) it just doesnt work in firefox.Ive searched a lot for a long time for a way to copy text in a textarea to the clipboard but in vain.All i get is codes that dont work or that the only way it can work is to edit the prefs.js file in firefox on my computer but i want the copy command to work on all computers when used on my site. I cant tell users to edit filesPlease help im really in a fix Ive heard about firefox extenstensiona as the only other solution which i dont want to use for the above reason. Link to comment Share on other sites More sharing options...
iyeru42 Posted March 22, 2007 Share Posted March 22, 2007 Then why not use your first code? It seems that works in both. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 22, 2007 Share Posted March 22, 2007 the first code selects the text the second could copies the selection to the clipboard. Link to comment Share on other sites More sharing options...
iyeru42 Posted March 22, 2007 Share Posted March 22, 2007 Oh right, missed that part. By the way, execCommand is probably not part of Firefox. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 22, 2007 Share Posted March 22, 2007 IE is notorius for creating their on method of doing things and ignoring standards. I imagine this is the case again. Link to comment Share on other sites More sharing options...
chrispey Posted July 29, 2009 Share Posted July 29, 2009 Does anyone know a standard script for copying a textarea then? Link to comment Share on other sites More sharing options...
jeffman Posted July 29, 2009 Share Posted July 29, 2009 I haven't checked it in FF3.5, but execCommand () used to work fine in FF (Safari, too, for that matter). But the permitted functions were always more security-minded than the IE implementation that it imitates. Since "copy" affects the system-wide clipboard (it does, right?) FF/Mozilla may have decided that that extends the scope of javascript too far. As a user, I know I wouldn't want my clipboard subject to a page-designer's whim. Functions like "bold" and "forecolor" always worked fine. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 29, 2009 Share Posted July 29, 2009 It's not possible for Javascript to access the clipboard in Firefox without changing configuration settings, it's disabled by default. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now