PDA

View Full Version : make the floating menu stay in same position although screen resolution is changed



sharon11
04-10-2010, 10:20 PM
I have a floating menu that on the right of my page. I want to make the floating menu just exactly beside from my table. But, it position is change and interlace my table when my screen resolution is changing.
How to make the floating menu stay in same position although screen resolution is change?

<script>
if (!document.layers)
document.write('<div id="divStayTopRight" style="position:absolute">')
</script>

<layer id="divStayTopRight">

<!--EDIT BELOW CODE TO YOUR OWN MENU-->

<table border="1" width="20px" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="#800000" align="center">
<a href="#">
REGISTER
</a>
</tr>
</table>

<!--END OF EDIT-->

</layer>


<script type="text/javascript">

//Enter "frombottom" or "fromtop"
var verticalpos="frombottom"

if (!document.layers)
document.write('</div>')

function JSFX_FloatTopDiv()
{
var startX = 0,
startY = 420;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.right=x;this.style.top=y;};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopRight=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopRight()", 10);
}
ftlObj = ml("divStayTopRight");
stayTopRight();
}
JSFX_FloatTopDiv();
</script>