Copying html text with format to clipboar?

S

Son KwonNam

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.
 
T

Thomas 'PointedEars' Lahn

^^^^^^^^^
And I dislike people who falsify sender addresses and spoil namespaces, too.
Tough luck.


PointedEars
 
S

SteveSu

I´m 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
 
R

RobG

SteveSu said:
I´m 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.
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 11/30/2005 8:36 PM:
^^^^^^^^^
And I dislike people who falsify sender addresses and spoil namespaces, too.
Tough luck.

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

SteveSu

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top