pasteHTML not working properly

Discussion in 'Javascript' started by colinhumber, Aug 9, 2005.

  1. colinhumber

    colinhumber Guest

    I'm running this line of code:

    oTarget.pasteHTML(formattedHtmlText);

    where oTarget is a text range object.

    When formattedHtmlText is, say, "<STRONG><BUTTON
    class=placeHolder>[[ContAmt]]</BUTTON>&nbsp;text</STRONG>" the HTML is
    pasted properly and the UI is changed accordingly.

    However, if formattedHtmlText is "<BUTTON
    class=placeHolder>[[ContAmt]]</BUTTON>&nbsp;text" the HTML is not
    pasted and there is no change in the UI.

    Any thoughts? Thanks!
     
    colinhumber, Aug 9, 2005
    #1
    1. Advertising

  2. colinhumber wrote:

    > I'm running this line of code:
    >
    > oTarget.pasteHTML(formattedHtmlText);
    >
    > where oTarget is a text range object.


    > However, if formattedHtmlText is "<BUTTON
    > class=placeHolder>[[ContAmt]]</BUTTON>&nbsp;text" the HTML is not
    > pasted and there is no change in the UI.


    The documentation here
    <http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/pastehtml.asp>
    says: "This method might alter the HTML text to make it fit the given
    text range. For example, pasting a table cell into a text range that
    does not contain a table might cause the method to insert a table
    element. For predictable results, paste only well-formed HTML text that
    fits within the given text range."

    So the results depend on where you try to paste some HTML snippet and on
    what IE regards as "well-formed HTML text fitting" into a given range.

    Perhaps it helps to wrap the above into <span></span> but as you have
    not even said us where you try to paste the above HTML it is not
    possible to test whether that helps.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Aug 9, 2005
    #2
    1. Advertising

  3. colinhumber

    colinhumber Guest

    Thanks for the reply. It's being pasted inside a <div> tag.
     
    colinhumber, Aug 9, 2005
    #3
    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. John Wallace

    Using pasteHTML in an MSHTML control

    John Wallace, Sep 12, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    313
    John Wallace
    Sep 12, 2003
  2. Simon Wigzell

    pasteHTML

    Simon Wigzell, Apr 19, 2004, in forum: Javascript
    Replies:
    3
    Views:
    119
    Simon Wigzell
    Apr 20, 2004
  3. colinhumber

    Problems with pasteHTML

    colinhumber, Sep 19, 2005, in forum: Javascript
    Replies:
    6
    Views:
    120
    Randy Webb
    Sep 23, 2005
  4. Rauan Maemirov

    iframe pasteHTML

    Rauan Maemirov, Feb 15, 2008, in forum: Javascript
    Replies:
    3
    Views:
    135
    Rauan Maemirov
    Feb 18, 2008
  5. geevaa

    pasteHTML for Firefox?

    geevaa, May 10, 2008, in forum: Javascript
    Replies:
    1
    Views:
    145
    Bart Van der Donck
    May 12, 2008
Loading...

Share This Page