Moving Elements
- Explorer - Position through the
style Object
- Netscape - Position through the
layer Object
<SCRIPT>
function getCSSPElement(id) {
// Retrieve a positioned element
if (supportAll)
return document.all[id]
else
return document.layers[id]
}
function offsetLeft(el,amount) {
// Moves a positioned element and returns the new position
if (supportAll)
// IE4 exposes position using the pixelLeft property
return (el.style.pixelLeft+=amount)
else
// Netscape exposes position using the left property
return (el.left+=amount)
}
function moveHeader(id) {
// Cross-Browser routine to animate the header
var el = getCSSPElement(id)
if (el.direction==null) el.direction="right"
switch (el.direction) {
case "right":
if (offsetLeft(el,5)>55)
el.direction="left"
break;
case "left":
if (offsetLeft(el,-5)<-50)
el.direction="right"
}
}
function doLoad() {
if (supportAll || supportLayers)
window.setInterval('moveHeader("h")',100)
}
window.onload = doLoad;
</SCRIPT>
<BODY>
<H1>
<SPAN ID=h STYLE="position: relative">
Moving Elements
</SPAN>
</H1>