Forum Moderators: mack

Message Too Old, No Replies

DHTML with API

When my html page load it give an error

         

avenir

12:54 am on Nov 8, 2004 (gmt 0)

10+ Year Member



Hi everyone,

I am learning DHTML from a book and I have to move 2 words at the same time at the same coordinates. Now, I have a function "placeObects()" in my html code that calls a function "placeIt()" from my API page to move the 2 words, but instead of moving it gives me an error and I pored over the code an can't find the error. And if I take "onLoad="placeObjects();" " from the body tag there is no error.

Please, could someone help me with that?

Here is the HTML code and API code respectively:

<HTML>
<HEAD>
<TITLE>Avalon Books</TITLE>
<STYLE>
BODY {color:white; background-color:black}
</STYLE>
<script src="Avalon.js"></script>
<script>
function placeObjects()
{
placeIt("avalon", 175, 10);
PlaceIt("books", 175, 10);
PlaceIt("AB", 230, 40);
placeIt("Fiction", 5, 5);
placeIt("NFiction", 475, 5);
}
</script>
</HEAD>

<BODY onLoad="placeObjects();">

<DIV ID="avalon"
STYLE="background-color:black; font-size:24pt; font-weight:bold; position:absolute;
z-index:2">
AVALON
</DIV>

<DIV ID="books"
STYLE="color:red; font-style:italic; font-size:24pt; font-weight:bold; position:absolute;
z-index:1">
BOOKS
</DIV>

<DIV ID="AB"
STYLE="width:150; height:225; position:absolute; visibility:hidden">
<A HREF="ABStore.htm"><IMG SRC="AB.jpg" BORDER=0></A>
</DIV>

<DIV ID="Fiction"
STYLE="font-family:Arial,Helvetica,sans-serif;font-size:x-small;
width:120; position:absolute; visibility:hidden">
<CENTER><IMG SRC="Fiction.jpg"><BR>
<B>AB Sales Rank: #1<BR>
Fiction</B><BR>
<I>Before the Fall</I><BR>Jeffrey Unwin</CENTER>
</DIV>

<DIV ID="NFiction"
STYLE="font-family:Arial,Helvetica,sans-serif; font-size:x-small;
width:120; position:absolute; visibility:hidden">
<CENTER><IMG SRC="NFiction.jpg"><BR>
<B>AB Sales Rank: #1<BR>
Nonfiction</B><BR>
<I>Vietnam Memoirs</I><BR>Gen. John Hartford</CENTER>
</DIV>

</BODY>
</HTML>

API code

var inNS=false;
var inIE=false;
if (document.layers) inNS=true;
if (document.all) inIE=true;

function getObject(id)
{
if (isNS) obj="document."+id;
if (isIE) obj=id+".style";
var object=eval(obj);
return object;
}

function placeIt(id, x, y)
{
var object=getObject(id);
if (isNS)
{
object.moveTo(x, y);
}
else if (isIE)
{
object.pixelLeft=x;
object.pixelTop=y;
}
}

function shiftIt(id, dx, dy)
{
var object=getObject(id);
if (isNS)
{
object.moveBy(dx, dy);
}
else if (isIE)
{
object.pixelLeft=object.pixelLeft+dx;
object.pixelTop=object.pixelTop+dy;
}
}

function xCoord(id)
{
var object=getObject(id);
if (isNS) xc=object.left;
if (isIE) xc=object.pixelLeft;
return xc;
}

function yCoord(id)
{
var object=getObject(id);
if (isNS) yc=object.top;
if (isIE) yc=object.pixelTop;
return yc;
}

function hideIt(id)
{
var object=getObject(id);
if (isNS) object.visibility="hide";
if (isIE) object.visibility="hidden";
}

function showIt(id)
{
var object=getObject(id);
if (isNS) object.visibility="show";
if (isIE) object.visibility="visible";
}