By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,939 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,939 IT Pros & Developers. It's quick & easy.

Copying html text with format to clipboar?

P: n/a
I found some information about copying text to clipboard in IE,
but it does not preserve html formats.

Is this possible to copy some html area, and when I paste it into MS Word or Excel,
I could see the same fonts, table, colors, blah, blah... on Word or Excel??

Regards,
KwonNam.
Dec 1 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Son KwonNam <kw******@ihatespam.xxx> wrote:
^^^^^^^^^
And I dislike people who falsify sender addresses and spoil namespaces, too.
Tough luck.
PointedEars
Dec 1 '05 #2

P: n/a
Im interested in the same topic. I want to copy formated text from a
label (span) to word still having it formated with tables etc.
My code now looks like

window.clipboardData.setData("Text", mySpan.innerText);
or
window.clipboardData.setData("Text", mySpan.innerHTML);

Using the first line the text is copied unformated. Using the second
line the text is copied with the html-tags, which is then also visible
in Word when pasting.

Anyone have an idea on how to accomplich this?
Son KwonNam: Please let me know if you found the solution.

Thanks
/ Stefan

Dec 1 '05 #3

P: n/a
SteveSu wrote:
Im interested in the same topic. I want to copy formated text from a
label (span) to word still having it formated with tables etc.
My code now looks like

window.clipboardData.setData("Text", mySpan.innerText);
or
window.clipboardData.setData("Text", mySpan.innerHTML);

Using the first line the text is copied unformated. Using the second
line the text is copied with the html-tags, which is then also visible
in Word when pasting.

Anyone have an idea on how to accomplich this?
Son KwonNam: Please let me know if you found the solution.


You need to think about what is happening. If what you copy is not a
valid HTML document or document fragment, what should the receiving
application do with it? What will the clipboard do with it?

Look at Edit -> Paste special in Word to see what your options are.


--
Rob
Dec 1 '05 #4

P: n/a
Thomas 'PointedEars' Lahn said the following on 11/30/2005 8:36 PM:
Son KwonNam <kw******@ihatespam.xxx> wrote:
^^^^^^^^^
And I dislike people who falsify sender addresses and spoil namespaces, too.
Tough luck.


But at least it's not a forged sender address :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 1 '05 #5

P: n/a
Thanks for the reply RobG!
Using window.clipboardData.setData("Text", mySpan.innerHTML); i got
html in the clipboard.
I tried to do a "paste special" in Word but my only options are
Unformatted Text and Unformated Unicode-Text which both results in the
html being pasted into word.
Do you know how I can make it work?

Dec 1 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.