faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

239 of 293 people (82%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

what is insertAdjacentHTML() function in javascript

Apr 4th, 2008 20:39
ha mo, Alex Fenton, amrapali basak, http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/ihtmlelement/insertadjacenthtml.asp


insertAdjacentHTML() is an Internet Explorer only method for adding 
dynamic HTML content onto an existing page element. You can call it 
upon any HTML element in the page. You give it two parameters, the 
first of which tells the browser where you want to put the new HTML in 
relation to the existing HTML in the tag, and the second of which is 
the HTML you want to add.
You use it something like:
<P ID="my_little_paragraph">some stuff</P>
<SCRIPT LANGUAGE="Javascript">
var para = document.all['my_little_paragraph'];
para.insertAdjacentHTML('BeforeBegin','<B>here</B>'); /* is now 
<B>here</B><P>some stuff</P> */
para.insertAdjacentHTML('AfterBegin','<I>there</I>'); /* is now 
<B>here</B><P><I>there</I>some stuff</P> */
para.insertAdjacentHTML('BeforeEnd','<U>everywhere</U>'); /* is now 
<B>here</B><P><I>there</I>some stuff<U>everywhere</U></P> */
</SCRIPT>
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com