Copy to Clipboard that also works on Mobile?

后端 未结 2 1643
盖世英雄少女心
盖世英雄少女心 2020-12-16 02:07

I\'m familiar with ZeroClipboard and jquery.copy, which both use Flash. OK, so I get it, for browser security reasons, copying is disallowed and we need Flash. But this mean

2条回答
  •  自闭症患者
    2020-12-16 02:40

    There is not a great solution to do this without using flash. I would just keep it simple and allow your users to copy the text themselves. It's how google serves their analytics code to users to embed on their sites. I'm sure if there was a great way to do it that google would be using it.

    Keeping it simple:

    $(function(){
        $('.text').click(function(){
            $(this).select();
        });
    });
    

    Focus event: http://jsfiddle.net/khXjC/

    Click event: http://jsfiddle.net/qjfgoeLm/

提交回复
热议问题