pasteHTML not working properly

C

colinhumber

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!
 
M

Martin Honnen

colinhumber said:
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/d.../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.
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top