Log in

View Full Version : function dysfunction: missing a clue with javascript



scott4design
10-21-2008, 04:56 PM
1) Script Title: Floating Menu Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/staticmenu.htm

3) Describe problem:
I saw this menu on www.starbucks.com and I found a script that would give me a similar action for a site I am developing. On DD I found http://www.dynamicdrive.com/dynamici...icmenu_dev.htm and installed it, checking all the code and comparing it ot the source on DD and I cannot see a difference. I have it loaded on http://achtungmediadesign.com/th/index2.html ...anyone have some thoughts. I want to reposition this and have it floaty ... scott

Nile
10-22-2008, 12:44 AM
Here you go:
http://www.quirksmode.org/css/position.html
Read about the fixed position. Then take a look at how to fix it in IE:
http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=Xgm&q=fixed+position+hacks+in+ie&btnG=Search

jscheuer1
10-22-2008, 05:53 AM
That script is outdated, use this version:


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

<layer id="divStayTopLeft">

<!--EDIT BELOW CODE TO YOUR OWN MENU-->
<table border="1" width="130" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="#FFFFCC" align="center">
<b><font size="4">Menu</font></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#FFFFFF">
<span>*<a href="http://www.dynamicdrive.com">Dynamic Drive</a><br>
*<a href="http://www.dynamicdrive.com/new.htm">What's New</a><br>
*<a href="http://www.dynamicdrive.com/hot.htm">What's Hot</a><br>
*<a href="http://www.dynamicdrive.com/faqs.htm">FAQs</a><br>
*<a href="http://www.dynamicdrive.com/morezone/">More Zone</a></span></td>
</tr>
</table>
<!--END OF EDIT-->

</layer>


<script type="text/javascript">

/*
Floating Menu script- Roy Whittle (http://www.javascript-fx.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/

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

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


function JSFX_FloatTopDiv()
{
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
var startX = 3,
startY = 150;
var PX='px', 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,PX='';}
el.sP=function(x,y){el.style.left=x+PX;el.style.top=y+PX;};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = window.innerHeight ? pageYOffset + window.innerHeight : ietruebody().scrollTop + ietruebody().clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function()
{
if (verticalpos=="fromtop"){
var pY = window.innerHeight ? pageYOffset : ietruebody().scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = window.innerHeight ? pageYOffset + window.innerHeight : ietruebody().scrollTop + ietruebody().clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopDiv();
</script>

scott4design
10-23-2008, 03:00 PM
Thank you John... I am going to play with it and change the position. I want to anchor it with a menu like on www.starbucks.com ... this is where I got the idea. THANK YOU!