Forum Moderators: not2easy

Message Too Old, No Replies

Layers with Relative Position and mouseover image

Trying to get layer to stay in one place while using a image to show ...

         

clearlycomputers

8:18 pm on Dec 13, 2006 (gmt 0)

10+ Year Member



I was just wondering if someone could shed some light on how to make a layer appear while using relative positioning. I have been working on it for two days now and did a search on the web but couldn't find anything. The code that I have for it is

Defining Layer
"<div id="Autonomy" style="position:relative; left:556px; top:260px; width:207px; height:125px; z-index:2; visibility: hidden;"></div>"

Image that user is going to mouseover to show the layer
"<img src="/images/autonomy_off.gif" width="75" height="13" border="0" id="Image2" onmouseover="MM_showHideLayers('Autonomy','','show');MM_swapImage('Image2','','/images/autonomy_on.gif',1)" onmouseout="MM_swapImgRestore();MM_showHideLayers('Autonomy','','hide')" />"

Can someone help me to get this to work proper. If their is a easier way to do it please let me know.

holyhttp

4:37 am on Dec 14, 2006 (gmt 0)

10+ Year Member



Hi clearlycomputers,

It's hard to provide a solution to your problem without seen the bit of javascript code that activates the dispaly of that layer.

Instead of "show" and "hide" the visibility property should be set to "visible" and "hidden" in your javascript. So you need to look into your javascript.
Let me know how it goes.

clearlycomputers

11:30 am on Dec 14, 2006 (gmt 0)

10+ Year Member



Sorry about that. This is the code that Dreamweaver creates for me.

<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}

It also creates a CSS section of code. I have been trying to modify that to position the layer but as soon as I change the position to relative it throws the whole page off. This is what it usually looks like

#SRED {
position:absolute;
left:556px;
top:260px;
width:207px;
height:125px;
z-index:1;
visibility: hidden;
}

It works with the mouse over but is doesn't stay where I want it to stay on the page.

clearlycomputers

1:27 pm on Dec 14, 2006 (gmt 0)

10+ Year Member



One more thing about this. I have tried changing absolute in the css code to relative but as soon as I do that the show/hide of the layer doesn't work.

clearlycomputers

10:19 pm on Dec 14, 2006 (gmt 0)

10+ Year Member



I finally figured it out. Thank You to everyone.