InnerText & InnerHTML In DHTML

The entire DHTML language is fairly substantial. It contains keywords for all sorts of things – dynamic event handling, text substitution, dynamic element creation, and so on. A discussion of these is beyond the scope of this tutorial, but there are a few features that we can explore.
An Example of innerHTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">



<TITLE>[Smart Cursor]</TITLE>

<META content="text/html; charset=windows-1252" http-equiv=Content-Type>


function moveMouse() {



di='<span style="background-color:#99CCFF; width:240">Welcome to 
<font color=red></font> Pvt Ltd.';


diC='<br />Current Mouse Postion : ';

if ('D') {



else {







<META content="MSHTML 5.00.2314.1000" name=GENERATOR>


<BODY onmousemove="javascript:moveMouse();" bgcolor="#0099FF">

<DIV id=D 

style="BACKGROUND-COLOR: #00CCFF; HEIGHT: 200px; LEFT: 100px; 
POSITION: absolute; TOP: 100px; WIDTH: 300px">


<P id=CC style="POSITION: absolute"></P>



Click here to view the page.
We create a DIV element that changes the cursor, and a P element that holds the cursor position. We call the script with the onmousemove event handler, which is fired every time the mouse moves.
The moveMouse() function re-positions CC to the mouse pointer. We can detect the element that fired the mousemove event with event.srcElement. We read the id of this element, and respond.
The idea is for the cool cursor to be rendered in bold if we are over the DIV. If we are over the DIV, then eH='<B>’, and eHc='</B>’. When we write the to innerHTML property, we either write:
if we are over the DIV, or just
if we are not over the DIV.
The HTML is then parsed by the document, and you can see the change that occurs.
Scroll to Top