Hi people,
I am new to HTC programming. I want to write some "label" like those in
www.techweb.com . I can do that with client-side javascript, but
unfortunately when I use HTCs that doesn't work.
That's without HTC:
<HTML>
<HEAD><TITLE>Label works</TITLE>
<STYLE>
#dyndiv {border : solid gray thin;
background-color:rgb(229,229,229);position:absolute;width:200px;}
BODY {cursor:default;}
</STYLE>
</HEAD>
<BODY>
<SCRIPT>
var divExist =3D false;
var divclass;
var oDiv;
function ShowLabel(el)
{
if (divExist =3D=3Dfalse) {
oDiv =3D document.createElement("DIV");
oDiv.id =3D "dyndiv";
divclass =3D oDiv.id;
oDiv.innerText =3D el.getAttribute("LABEL");
document.body.appendChild(oDiv);
divExist =3D true;
}
document.all[divclass].style.top =3D event.clientY + 2;
document.all[divclass].style.left =3D event.clientX +10;
}
function HideLabel()
{
document.body.removeChild(oDiv);
divExist =3D false;
}
</SCRIPT>
This page will contain labels in a minute....<BR>
<SPAN CLASS=3Dlabeled LABEL=3D"This is the label to be display on the
mouse over event" onmousemove=3D"ShowLabel(this);"
onmouseout=3D"HideLabel();">Hello World!</SPAN><BR>
<A CLASS=3Dlabeled LABEL=3D"Here's a second page"
onmousemove=3D"ShowLabel(this);" onmouseout=3D"HideLabel();">Sec.
Anchors</A>
</BODY>
</HTML>
It works GREAT. It displays whatever I write in the LABEL attribute. Now
I tried that with the same code , this time with an HTC file:
This is the HTML file.
<HTML>
<HEAD>
<STYLE>
.labeled {behavior: url(label.htc);}
#dyndiv {border : solid gray thin;
background-color:rgb(229,229,229);position:absolute;width:200px;}
BODY {cursor:default;}
</STYLE>
</HEAD>
<BODY>
<H1>Welcome1654646</H1>
<A CLASS=3Dlabeled LABEL=3D"This is text should be shown on a
label....">This is an anchor text </A>
</BODY>
</HTML>
And this is the HTC file, the source of all the problems:
<ATTACH EVENT=3D"onmouseout" ONEVENT=3D"ClearLabel()" />
<ATTACH EVENT=3D"onmousemove" ONEVENT=3D"ShowLabel()" />
<SCRIPT LANGUAGE=3D"Javascript">
var divExist =3D false;
var oDiv;
var divclass =3D "dyndiv";
function ShowLabel()
{
window.alert(this.getAttribute("LABEL"));
if (divExist =3D=3D false) {
oDiv =3D document.createElement("DIV");
oDiv.id =3D divclass;
oDiv.innerText =3D this.getAttribute("LABEL");
document.body.appendChild(oDiv);
divExist =3D true;
}
document.all[divclass].style.top =3D event.clientY + 2;
document.all[divclass].style.left =3D event.clientX +10;
}
function ClearLabel()
{
document.body.removeChild(oDiv);
divExist =3D false;
}
</SCRIPT>
As you'll see if you run the codes, nothing happens with the htc file. I
get no error either. What's the problem??
Thanks a lot if you read all that and find the problem......