Ocean West Posted February 16, 2015 Posted February 16, 2015 Playing round with the new content databases - and was wondering if it is possible to include some code to generate a "copy button" which would appear next to a field when others are reading the display template of the record - so they can easily copy the content to their clipboard.this is code[ copy to clipboard]
Makoto Posted February 17, 2015 Posted February 17, 2015 I've spent a bit of time researching this and trying to find potential solutions for my own applications. As far as I am aware, it is not possible to copy data to the users clipboard using Javascript.It's mostly a security concern. I believe there was once a bug that allowed you to abuse some HTML 5 API and accomplish this, but it has long since been fixed.I don't think there's any other way to do this. You can select text for the user, but you can't copy text to the clipboard for them.tl;dr No.
Ocean West Posted February 17, 2015 Author Posted February 17, 2015 Some sites I visit use flash (not preferred) but also saw http://stackoverflow.com/questions/10729570/html5-alternative-to-flash-based-zeroclipboard-for-safe-copying-of-data-to-clipbat the very least if not copy to clipboard perhaps download as txt would suffice.
Makoto Posted February 17, 2015 Posted February 17, 2015 Oh right I'm sorry. Yeah, I believe you can accomplish it using flash plugins like Zeroclipboard.I was explicitly searching for ways to do it without needing flash but I never found anything. I did come across the Clipboard API you are referencing, I actually found it from that very same SO post, but it doesn't seem to work in any browser I've tested currently.A bit dissapointing, but maybe it will be an option in the not so distant future. At the very least it could be implemented as something similar to other browser API's like GeoLocation and desktop notifications, where it prompts the user for permission before granting the website access to the clipboard.
Ocean West Posted February 17, 2015 Author Posted February 17, 2015 Thanks for the info. Perhaps there will be more renewed interest for this after release and every one has had months on the new platform. ( now that IPC is much more easier to understand then 3x version people may venture in to come custom creation needing the same feature.
Makoto Posted February 17, 2015 Posted February 17, 2015 It's nothing specific to IP.Board, it's just currently impossible to do with Javascript in general.You could still integrate a flash plugin like Zeroclipboard yourself if you really wanted.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.