I am developing web development tools and I'd like to copy of a part of current web page's HTML code to the clipboard using Javascript.

This probably would involve

* Getting the piece of HTML in the question using DOM innerHTML
* Copying this text to clipboard using Javascript

Is anyone aware of any gotchas here? E.g. related to clipboard handling - when one is not using documentEditable mode do I need to create a hidden where to put the HTML payload for copying? 

Also if possible I'd like to make the interaction with WYSIWYG components, like TinyMCE, work so that when one pastes the HTML in the visual edit mode it comes through as formatted HTML instead of plain text.

It is enough if solution works in Chrome and Firefox. Internet Explorer does not need to be supported.