[Project_owners] How to insert text as HTML?

Michael Vincent mv_van_rantwijk at yahoo.com
Wed Aug 31 01:59:08 EDT 2005

Eric Jung wrote:
> Use the DOM Core Level 1 API
> http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html
> var myDiv = document.getElementById("mydiv");
> var link = document.createElement("a");
> var linkText = document.createTextNode("MultiZilla");
> link .setAttribute("href", "http://multizilla.mozdev.org/");
> link .appendChild(linkText);
> myDiv.appendChild(link);

Thanks Eric, but I'm afraid that my HTML example snippet was not clear 
enough because what I need really is to insert that link inside a <p> 
element, at a given position. Lets take this example:

<p>Here's a better test</p>

and the text 'better' should become my link, so how does that work?


> --- Michael Vincent <mv_van_rantwijk at yahoo.com> wrote:
>> Hi,
>> I have a string with HTML code that I need to insert in a HTML
>> document, 
>> inside a <div> element, but how should that be done?
>> Lets take this example:
>> "<a href="..">my link</a>"
>> That should be inserted, as HTML, in a <div> element and it should
>> be 
>> HTML i.e. a true link, not the above text!
>> Thanks for your help/tips,
>> Michael

More information about the Project_owners mailing list