Jump to content

Javascript Copy(clipboard) Not Working In Ff3


Recommended Posts

Javascript Copy(clipboard) not working in FF3. Only works in IE6 as far as I can tell9no IE7 to test with at work). It doesn't do anything when clicked in FF.Did a quick search of the boards, and google... but apparently with Flash10 all of their solutions(used a flash script to copy, was pretty neat solution that worked until now).So, I'm going back to the old original IE only script... Any idea's from this board on getting it working in FF3?In header:

<script language="JavaScript" type="text/javascript">function ClipBoard(){holdtext.innerText = htmlArea.innerText;Copied = holdtext.createTextRange();Copied.execCommand("Copy");}</script>

textarea is:

<textarea name="htmlArea">

button is:

<input style="width:100px;font-size:12pt;font-weight:bolder;text-align:center;" type="button" value="Copy" onclick="ClipBoard();">

Link to post
Share on other sites

First, you should be using getElementById() instead of old-fashioned names.Second, createTextRange() is a Microsoft method, not a W3 DOM method. W3 has its own methods for creating text ranges.Third, although execCommand() is also a MS method, Firefox does implements it. I've never tried using the "copy" argument before, so I don't know if that part works in FF. In any case, the FF version expects more arguments.So you have some things to look up. :)

Link to post
Share on other sites

Isn't that function a bit dangerous, security-wise? For example, a web page could constantly overwrite the clipboard, preventing anything else from being copied.

Link to post
Share on other sites
Isn't that function a bit dangerous, security-wise? For example, a web page could constantly overwrite the clipboard, preventing anything else from being copied.
Yeah, the other sites I ran across when looking it up labeled security as the reason Firefox doesn't like it. (And it's not as if MS is known for being security-conscious.)
Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...