Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > pasteHTML not working properly

Reply
Thread Tools

pasteHTML not working properly

 
 
colinhumber
Guest
Posts: n/a
 
      08-09-2005
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!

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      08-09-2005


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/
 
Reply With Quote
 
 
 
 
colinhumber
Guest
Posts: n/a
 
      08-09-2005
Thanks for the reply. It's being pasted inside a <div> tag.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pasteHTML for Firefox? geevaa Javascript 1 05-12-2008 07:37 AM
iframe pasteHTML Rauan Maemirov Javascript 3 02-18-2008 11:11 AM
Problems with pasteHTML colinhumber Javascript 6 09-23-2005 08:17 PM
pasteHTML Simon Wigzell Javascript 3 04-20-2004 03:22 AM
Using pasteHTML in an MSHTML control John Wallace ASP .Net Web Controls 0 09-12-2003 07:38 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57