470,619 Members | 1,841 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

pasteHTML not working properly

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!

Aug 9 '05 #1
2 1818


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/
Aug 9 '05 #2
Thanks for the reply. It's being pasted inside a <div> tag.

Aug 9 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Simon Wigzell | last post: by
10 posts views Thread by colinhumber | last post: by
4 posts views Thread by qbproger | last post: by
1 post views Thread by geevaa | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.