Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As already previously mentioned, modifying the clipboard data is either restricted to specific browsers or requires the user to grant access to modifying the clipboard. A work around to this you could </p> <ol> <li>Add an event handler to the <code>oncopy</code> event</li> <li>Find the selection</li> <li>Prepend/append content to the content</li> <li>Modify the selection range to include the appended/prepended content</li> <li>Wait for the copy action to push through</li> <li>Remove the appended/prepended content</li> </ol> <p>I fiddled about with this method and created a plugin which does just that. Still a preliminary version and only tested on FF4/Chrome 11/IE8 so far (and IE definetly needs to have some more work done). Some of the nice things you can do with this method is that you could easily for example wrap forum post quotes in <code>[quote=USER]content[/quote]</code> and assign the user based on which post is copied. By default, the script always selects the DOM styling, but not the actual HTML, so if you for example copy <strong>bold</strong> content, it would be bold if pasted into a rich text editor, but just text if used in text only editors (removing the html tags).</p> <p>Prepending content is significantly easier with this method, compared to appending, in which case I still am not sure whether it is fully functional. For IE, you could directly modify the clipboard, but there are some issues for example when selecting the whole page, or if you want to toggle the rich copy content. Haven't had the chance to do any further browser testing, but this appears to be at least a working solution for newer browsers.</p> <p>Example: <a href="http://hertzen.com/experiments/jquery.plugin.clipboard/" rel="noreferrer">http://hertzen.com/experiments/jquery.plugin.clipboard/</a></p> <p>Another example: <a href="http://hertzen.com/experiments/jquery.plugin.clipboard/thread.html" rel="noreferrer">http://hertzen.com/experiments/jquery.plugin.clipboard/thread.html</a></p> <p>Source code: <a href="https://github.com/niklasvh/jquery.plugin.clipboard" rel="noreferrer">https://github.com/niklasvh/jquery.plugin.clipboard</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload