views:

924

answers:

1

I had implemented copy to clipboard functionality. It is working fine with all version on IE but not working in FireFox. Please help me solve out this problem. Detail are

<script src="../../Scripts/JQPlugins/jquery.clipboard.js" type="text/javascript"></script>

<script src="../../Scripts/JQPlugins/jquery.clipboard.pack.js" type="text/javascript"></script>   
 <script type="text/javascript">
        $.clipboardReady(function() {
            $("input#buttonid").bind('click', function() {
                var text = $("#url").attr("href") + "\n" + $("#pwd").html();
                $.clipboard(text);
                alert("hi");
                return false;
            });
        }, { swfpath: "../../Scripts/JQPlugins/jquery.clipboard.swf", debug: true }); 

    </script> 

And my code file structure is

Project > Scripts > JQPlugins > 
1. jquery.clipboard.js
2. jquery.clipboard.pack.js
3. jquery.clipboard.swf
+5  A: 

The method you're using to copy text to the clipboard is the jQuery clipboard plugin; it uses IE's native abilities to copy text to the clipboard, but uses a Flash plugin on non-IE platforms. My bet is that you have Flash 10 on your machine, or at least on the machine you're testing Firefox on -- Flash 10 no longer allows clipboard manipulation without explicit user request, which is likely why you're seeing it not work on Firefox. (This is even mentioned in the release notes for the plugin.)

That being said, people have already figured out a workaround for the security restrictions; the workaround involves placing an invisible Flash movie atop the DOM element of your choice, which means that when the user clicks or otherwise invokes the element to submit data, the Flash movie registers that the user took explicit action, and allows the clipboard manipulation. Zero Clipboard is one such library providing the workaround, but there are others out there if you look for 'em.

delfuego
Thanks @@delfuego.. you are my only signal hope.. Please tell me what should i do to fix this issue? may i change the code and move to other kind of implementation or try other things?
Pankaj
Pankaj, I've shown you one option you have -- move to the linked Zero Clipboard library. There is a well-put-together instructions page on their site explaining how you integrate it into your project.
delfuego
Fascinating that this got a downvote, by the way... what gives? Not that I care, I'm just baffled... oh, I see, there looks to be someone (easy to guess) who's systematically going through and downvoting my contributions to the site. Nice, nice.
delfuego
Thanks @@Delfuego... i am trying Zero Clipboard.but i think still this functionality is some problem with Fierfox and some other browser also in https.And one more thing you have really a good knowledge so no-one can downvote your contributions anywhere.He is downvote himself.
Pankaj