views:

139

answers:

1

I've managed to write some jQuery to find an element and copy it's html to the clipboard (ie only).

The problem is that when I paste this into a rich text box area in sharepoint it pastes the HTML as text only.

How do i replicate the user action of highlighting a link on a page and pressing copy. When I do this manually and then paste the clipboard contents the rich text area realises that it is markup and replicates the link as an anchor in the text content.

A: 

Unfortunately, as far as I know the only programmatic access IE gives to the clipboard allows you to set text data and URL data, but nothing else: http://msdn.microsoft.com/en-us/library/ms536744(v=VS.85).aspx

This works:

window.clipboardData.setData("text", "<div>Testing</div>");

...but has the problem you mentioned. Sadly, this doesn't work:

window.clipboardData.setData("html", "<div>Testing</div>");

A bit surprising, really.

T.J. Crowder
strangely enough I was just testing whether i could put "html" in there. :-)
Brian Scott