Click to See Complete Forum and Search --> : Please Help: Amateur Doubt In Javascript For Webpage


god_is_senile
05-29-2004, 04:23 PM
i get runtime errors when i run the following html file, every time.
the error is: "object1 is undefined", in line 41 and line 54

i've spotted the lines and the object1's but i don't know how to do anything about it.

please help. would greatly appreciate it.

here is the entire html document:


-----------------------


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Bharathi Lipi is a creation of Shri. K. Kasturi &amp; Shri. G.
Kasturi</TITLE>
<META http-equiv=Content-Language content=en-us>
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
// ############## SIMPLE BROWSER IDENTIFIER
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}



// ######### POPUP TEXT
descarray = new Array(
"</center>Installing <b>Bharathi</b> font onto your computer.<br><br> 1. Go to CONTROL PANEL.<br> 2. Select FONTS.<br>(If you cannot see it, click 'Switch to Classic View' on the left side of your window.)<br> 3. Select INSTALL NEW FONT from the FILE menu.<br> 4. Select the folder into which you downloaded <i>Bharathi_Font.ttf.</i><br> 5. Select 'Bharathi Font (TrueType)'.<br> 6. Click OK to Install this font."
);

overdiv="0";

// ######### CREATES POP UP BOXES
function popLayer(a){
if(!descarray[a]){descarray[a]="<font color=red>This popup (#"+a+") isn't setup correctly - needs description</font>";}
if (navigator.family == "gecko") {pad="1"; bord="1 bordercolor=black";}
else {pad="1"; bord="0";}
desc = "<table cellspacing=1 cellpadding="+pad+" border="+bord+" bgcolor=000000><tr><td>\n"
+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td bgcolor=dfffdd><center><font size=3 face=arial>\n"
+descarray[a]
+"\n</td></tr></table>\n"
+"</td></tr></table>";
if(navigator.family =="nn4") {
document.object1.document.write(desc);
document.object1.document.close();
document.object1.left=x+15;
document.object1.top=y-5;
}
else if(navigator.family =="ie4"){
object1.innerHTML=desc;
object1.style.pixelLeft=x+15;
object1.style.pixelTop=y-5;
}
else if(navigator.family =="gecko"){
document.getElementById("object1").innerHTML=desc;
document.getElementById("object1").style.left=x+15;
document.getElementById("object1").style.top=y-5;
}
}
function hideLayer(){
if (overdiv == "0") {
if(navigator.family =="nn4") {eval(document.object1.top="-500");}
else if(navigator.family =="ie4"){object1.innerHTML="";}
else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
}
}

// ######## TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;
// End -->
</script>






</HEAD>
<BODY text=#000000 bgColor=#FFFFFF link="#000000" vlink="#000000" alink="#808080">
<blockquote>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1">
<tr>
<td>
<p style="line-height: 150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#000080">[Annexure V]</font></p>
<p style="line-height:150%" align="justify"><b>
<font face="Georgia" color="#808080">Sample sentences. </font></b></p>
<p style="line-height:150%" align="justify"><font face="Georgia">&nbsp;Sample
sentences from various languages written in the Bharathi script.</font></p>
<p style="line-height: 150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#000080">[Annexure VI]</font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#808080">Keyboard layout </font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt">&nbsp;This annexure lays out the
Keyboard map to writing in the Bharathi script on a COMPUTER.</font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" color="#FFFFFF">
<span style="background-color: #66CCFF">
<a onMouseOver="popLayer(1)" onMouseOut="hideLayer()" target="_blank" style="text-decoration: none; font-weight: 700" href="Bharathi_Font.ttf">Click here to Download&nbsp; Bharathi font on your computer!</a></span></font></p>
<p style="line-height:150%" align="justify"><font face="Georgia">
{the file is&nbsp; Bharathi_Font.ttf&nbsp; - 12.9 KB<br>
move mouse over the Download link, to view instructions on how to install the
font} </font></p>
<p style="line-height: 150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#000080">[Annexure VII]</font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#808080">
Bharathi Font to the KEYBOARD</font></p>

<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt">&nbsp;Here is a helpful guide on
how to find the correct computer &quot;Key&quot; to type in a letter in Bharathi font.</font></p>

<p class="MsoNormal" style="line-height: 150%" align="justify">&nbsp;</p>

<p class="MsoNormal" style="line-height: 150%" align="justify">
<font color="#808080"><b><i><font face="Georgia"><span style="font-size: 11pt">&nbsp;&nbsp;
</span></font></i></b></font>
<i><font face="Georgia" color="#808080"><span style="font-size: 11pt">
Please click on the appropriate links to read more</span></font></i><br>
&nbsp;</p>

</td>
</tr>
</table>
</center>
</div>
</blockquote>

</BODY></HTML>

Tage
05-29-2004, 05:37 PM
You're missing an element with an ID of object1. So add<div id="object1" style="position:absolute"></div>to the end of the body tag, right above </body>. And on your <a> tag that is calling the function popLayer(), you need a 0 instead of a 1 because in arrays, the first array is always 0 and not 1. That </center> specified in your array is also not necessary.

Tage

P.S. Your code should look like this I guess.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Bharathi Lipi is a creation of Shri. K. Kasturi & Shri. G.
Kasturi</TITLE>
<META http-equiv=Content-Language content=en-us>
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
// ############## SIMPLE BROWSER IDENTIFIER
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}



// ######### POPUP TEXT
descarray = new Array(
"Installing <b>Bharathi</b> font onto your computer.<br><br> 1. Go to CONTROL PANEL.<br> 2. Select FONTS.<br>(If you cannot see it, click 'Switch to Classic View' on the left side of your window.)<br> 3. Select INSTALL NEW FONT from the FILE menu.<br> 4. Select the folder into which you downloaded <i>Bharathi_Font.ttf.</i><br> 5. Select 'Bharathi Font (TrueType)'.<br> 6. Click OK to Install this font."
);

overdiv="0";

// ######### CREATES POP UP BOXES
function popLayer(a){
if(!descarray[a]){descarray[a]="<font color=red>This popup (#"+a+") isn't setup correctly - needs description</font>";}
if (navigator.family == "gecko") {pad="1"; bord="1 bordercolor=black";}
else {pad="1"; bord="0";}
desc = "<table cellspacing=1 cellpadding="+pad+" border="+bord+" bgcolor=000000><tr><td>\n"
+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td bgcolor=dfffdd><center><font size=3 face=arial>\n"
+descarray[a]
+"\n</td></tr></table>\n"
+"</td></tr></table>";
if(navigator.family =="nn4") {
document.object1.document.write(desc);
document.object1.document.close();
document.object1.left=x+15;
document.object1.top=y-5;
}
else if(navigator.family =="ie4"){
object1.innerHTML=desc;
object1.style.pixelLeft=x+15;
object1.style.pixelTop=y-5;
}
else if(navigator.family =="gecko"){
document.getElementById("object1").innerHTML=desc;
document.getElementById("object1").style.left=x+15;
document.getElementById("object1").style.top=y-5;
}
}
function hideLayer(){
if (overdiv == "0") {
if(navigator.family =="nn4") {eval(document.object1.top="-500");}
else if(navigator.family =="ie4"){object1.innerHTML="";}
else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
}
}

// ######## TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;
// End -->
</script>






</HEAD>
<BODY text=#000000 bgColor=#FFFFFF link="#000000" vlink="#000000" alink="#808080">
<blockquote>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1">
<tr>
<td>
<p style="line-height: 150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#000080">[Annexure V]</font></p>
<p style="line-height:150%" align="justify"><b>
<font face="Georgia" color="#808080">Sample sentences. </font></b></p>
<p style="line-height:150%" align="justify"><font face="Georgia"> Sample
sentences from various languages written in the Bharathi script.</font></p>
<p style="line-height: 150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#000080">[Annexure VI]</font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#808080">Keyboard layout </font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt"> This annexure lays out the
Keyboard map to writing in the Bharathi script on a COMPUTER.</font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" color="#FFFFFF">
<span style="background-color: #66CCFF">
<a onMouseOver="popLayer(0)" onMouseOut="hideLayer()" target="_blank" style="text-decoration: none; font-weight: 700" href="Bharathi_Font.ttf">Click here to Download Bharathi font on your computer!</a></span></font></p>
<p style="line-height:150%" align="justify"><font face="Georgia">
{the file is Bharathi_Font.ttf - 12.9 KB<br>
move mouse over the Download link, to view instructions on how to install the
font} </font></p>
<p style="line-height: 150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#000080">[Annexure VII]</font></p>
<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt; font-weight:700" color="#808080">
Bharathi Font to the KEYBOARD</font></p>

<p style="line-height:150%" align="justify">
<font face="Georgia" style="font-size: 12pt"> Here is a helpful guide on
how to find the correct computer "Key" to type in a letter in Bharathi font.</font></p>

<p class="MsoNormal" style="line-height: 150%" align="justify"> </p>

<p class="MsoNormal" style="line-height: 150%" align="justify">
<font color="#808080"><b><i><font face="Georgia"><span style="font-size: 11pt">
</span></font></i></b></font>
<i><font face="Georgia" color="#808080"><span style="font-size: 11pt">
Please click on the appropriate links to read more</span></font></i><br>
</p>

</td>
</tr>
</table>
</center>
</div>
</blockquote>
<div id="object1" style="position:absolute"></div>
</BODY></HTML>