Jump to content

Javascript Copy(clipboard) Not Working In Ff3


Lonig

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 comment
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 comment
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 comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...