...

View Full Version : need a scrpit...any one help?



chefcs5
01-20-2006, 05:54 PM
i have a small icon/pic on my page and i would like it to follow the user as they scroll...i have never written a script and am new to using them but i am good w/ html and can do some php but would like to learn more about scripting..so if any one knows of one like this please let me know..thanks

email= chefcs5@yahoo.com

Mr J
01-20-2006, 07:16 PM
Give this a try


<script type="text/javascript">
<!--
function stayput() {

if (document.layers){
document.layers['layerName'].pageX = window.pageXOffset + 10
document.layers['layerName'].pageY = window.pageYOffset + 10
}

if (document.all){
document.all['layerName'].style.posLeft = document.body.scrollLeft + 450
document.all['layerName'].style.posTop = document.body.scrollTop + 150
}

if(document.getElementById){
document.getElementById("layerName").style.left = document.body.scrollLeft + 450
document.getElementById("layerName").style.top = document.body.scrollTop + 150
}

}

onscroll=stayput

//-->
</script>

Place your contents within the following DIV tags

<DIV ID="layerName" STYLE="position:absolute; left:450px; top:150px"> Your Stuff Here </DIV>

chefcs5
01-21-2006, 07:16 AM
thanks alot man worked great..

vwphillips
01-21-2006, 12:34 PM
document.getElementById("layerName").style.left = document.body.scrollLeft + 450
document.getElementById("layerName").style.top = document.body.scrollTop + 150


should be


document.getElementById("layerName").style.left = (document.body.scrollLeft + 450)+'px';
document.getElementById("layerName").style.top = (document.body.scrollTop + 150)+'px';


but is still not X-browser without something like


<script type="text/javascript">
<!--
function zxcWWHS(){
if (document.all){
zxcWH=document.documentElement.clientHeight;
if (zxcWH==0){
zxcWSL=document.body.scrollLeft;
zxcWST=document.body.scrollTop;
}
}
else if (document.getElementById){
zxcWSL=window.pageXOffset;
zxcWST=window.pageYOffset;
}
return [zxcWSL,zxcWST];
}

function stayput() {
document.getElementById("layerName").style.left = (zxcWWHS()[0]+150)+'px';
document.getElementById("layerName").style.top = (zxcWWHS()[1]+150)+'px';
}


window.onscroll=stayput

//-->
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum