Copying html text with format to clipboar?

Discussion in 'Javascript' started by Son KwonNam, Dec 1, 2005.

  1. Son KwonNam

    Son KwonNam Guest

    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.
    Son KwonNam, Dec 1, 2005
    #1
    1. Advertising

  2. Son KwonNam <> wrote:
    ^^^^^^^^^
    And I dislike people who falsify sender addresses and spoil namespaces, too.
    Tough luck.


    PointedEars
    Thomas 'PointedEars' Lahn, Dec 1, 2005
    #2
    1. Advertising

  3. Son KwonNam

    SteveSu Guest

    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
    SteveSu, Dec 1, 2005
    #3
  4. Son KwonNam

    RobG Guest

    SteveSu wrote:
    > 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.




    --
    Rob
    RobG, Dec 1, 2005
    #4
  5. Son KwonNam

    Randy Webb Guest

    Thomas 'PointedEars' Lahn said the following on 11/30/2005 8:36 PM:
    > Son KwonNam <> 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/
    Randy Webb, Dec 1, 2005
    #5
  6. Son KwonNam

    SteveSu Guest

    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?
    SteveSu, Dec 1, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rigga

    Format text from db into HTML text

    Rigga, Jun 8, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    632
    =?Utf-8?B?U2FlaWQ=?=
    Jun 11, 2005
  2. Replies:
    3
    Views:
    449
  3. Replies:
    1
    Views:
    373
    Jukka K. Korpela
    Jan 31, 2007
  4. Dominik
    Replies:
    4
    Views:
    2,371
    Dominik
    Mar 22, 2007
  5. Cristian
    Replies:
    2
    Views:
    430
    Michael Fesser
    Dec 15, 2007
Loading...

Share This Page