HTML5 alternative to flash-based ZeroClipboard for safe copying of data to clipboard?

前端 未结 6 1475
春和景丽
春和景丽 2020-12-02 14:22

With flash on the way out in many environments (iPhone, Android, IE10, etc...), is there any new solution forthcoming in any browsers that will allow a safe copy of informat

6条回答
  •  一整个雨季
    2020-12-02 14:52

    The reasoning is that automatic copying to clipboard can be very dangerous, thus most browsers (except IE)* make it difficult unless you use flash.

    Much like your ZeroClipboard, there is Clipboard LMCButton which also uses a small flash script running in the background.

    A common solution would be to do this:

     function copyToClipboard (text) {
         window.prompt ("Copy to clipboard: Ctrl+C, Enter", text);
     }
    

    Which I found from Jarek Milewski when some one else asked the question here

    *Yes I found one solution for IE, however does not work in most modern browsers, check here.

提交回复
热议问题