[Project_owners] How to insert text as HTML?
fry.kun at gmail.com
Tue Aug 30 17:39:36 EDT 2005
var myHtml = '<p>Here\'s a better test</p>';
myHtml.replace('better', '<a href="mysite">better</a>');
If I'm correct in assuming this is for an extension and you'll be
generating HTML on the fly on pages you have no other control over,
then innerHTML is probably your best bet. It is more efficient than
most other methods, simply because by setting innerHTML you call up
HTML parser/renderer once, while with other methods you have to call
them multiple times.
As an example of why this is important, take a page like
http://docs.python.org/lib/genindex.html - the CPU is loaded to 100%
for about 10 seconds after the page loads. I'm suspecting this is
caused by one of the extensions I have installed, TargetAlert - it
takes every link on the page and attaches an image to it if the link
opens a new window..
It may not be the same case for you, but keep it in mind in case you need it :)
On 8/30/05, Michael Vincent <mv_van_rantwijk at yahoo.com> wrote:
> <p>Here's a better test</p>
> and the text 'better' should become my link, so how does that work?
More information about the Project_owners