somnamblst
April 18th, 2007, 03:11 PM
I have a script that is moving a div down using body onload="appear();"
For the life of me I can not figure out what is determining the y coordinates. I realize that the top:-250px; determines where the div is prior to floating down. Changing var new_top = current_top + 5; doesn't seem to change anything
<script>
var timeout;
function appear(){
var the_style = getstyle("floatingflash");
if (the_style) {
var current_top = parseInt(the_style.top);
var new_top = current_top + 5;
if (document.layers) {
the_style.top = new_top;
} else {
the_style.top = new_top + "px";
}
if (new_top < 150) {
the_timeout = setTimeout('appear();',10);
}
}
} // appear
function disappear() {
var the_style = getstyle("floatingflash");
the_style.display = 'none';
} // disappear
function getstyle(ref) {
if(document.getElementById && document.getElementById(ref)) {
return document.getElementById(ref).style;
} else if (document.all && document.all(ref)) {
return document.all(ref).style;
} else if (document.layers && document.layers[ref]) {
return document.layers[ref];
} else {
return false;
}
} // getstyle
</script>
<div id="floatingflash" style="top:-250px;left:-150px;margin-left:80%; z-index:10;">
<a href="javascript:disappear();" style="position:absolute; top:240px; left:290px; font: normal small sans-serif; letter-spacing: 1px; color:white; text-decoration:none; font-size:8pt; height: 5px; z-index:1000;">X</a>
DIV CONTENT
</div>
For the life of me I can not figure out what is determining the y coordinates. I realize that the top:-250px; determines where the div is prior to floating down. Changing var new_top = current_top + 5; doesn't seem to change anything
<script>
var timeout;
function appear(){
var the_style = getstyle("floatingflash");
if (the_style) {
var current_top = parseInt(the_style.top);
var new_top = current_top + 5;
if (document.layers) {
the_style.top = new_top;
} else {
the_style.top = new_top + "px";
}
if (new_top < 150) {
the_timeout = setTimeout('appear();',10);
}
}
} // appear
function disappear() {
var the_style = getstyle("floatingflash");
the_style.display = 'none';
} // disappear
function getstyle(ref) {
if(document.getElementById && document.getElementById(ref)) {
return document.getElementById(ref).style;
} else if (document.all && document.all(ref)) {
return document.all(ref).style;
} else if (document.layers && document.layers[ref]) {
return document.layers[ref];
} else {
return false;
}
} // getstyle
</script>
<div id="floatingflash" style="top:-250px;left:-150px;margin-left:80%; z-index:10;">
<a href="javascript:disappear();" style="position:absolute; top:240px; left:290px; font: normal small sans-serif; letter-spacing: 1px; color:white; text-decoration:none; font-size:8pt; height: 5px; z-index:1000;">X</a>
DIV CONTENT
</div>