Jump to content

copying selected text in firefox


Guest ethicalhacker
 Share

Recommended Posts

Guest ethicalhacker

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

  • 2 years later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...