| Author |
Hiding Relatively Positioned Layer
|
Adnan Memon
Ranch Hand
Joined: Mar 09, 2003
Posts: 32
|
|
I have a very terrible issue I am hiding DIV layer which is relatively positioned but it still takes space when hidden.. when i change the positioning to absolute things work ok.. so how could i do same with relative posotion... or any work around? You help would be appreciated Adnan Memon
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
visibility takes open space. you want to use display. document.getElementById("id").style.display = "none"; "block" or "inline" for showing it Eric
|
 |
Adnan Memon
Ranch Hand
Joined: Mar 09, 2003
Posts: 32
|
|
Thanks Eric ... i set its display property to none.. now its not taking up space but I also want it not to take any space when it show up .. like we show absolute position layer by seting their visibility on. I hope you undersand my intensions. Thanks again Adnan Memon
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
when you use realtive it will take up space, that is the way the element reacts. What you can do is find the position of the element where you want it positioned and set i there. I have a post in my blog explainning how you can find the position of the element: http://radio.javaranch.com/channel/pascarello/2004/12/15/1103125502000.html Eric
|
 |
Adnan Memon
Ranch Hand
Joined: Mar 09, 2003
Posts: 32
|
|
I read your bolg now everthing is ok...i checked it on every browser it is running ok but on MacOS Safari 1.2.. no layer show up ... is there something wrong with safari or my code given below? HTML Layer: <div id='search_trail_layer' style='position:absolute; left:0px; top:0px; width:213px; height:76px; z-index:2; visibility: hidden;'> .... </div> JAVASCRIPT: *modified macromedia auto-generated code... function MM_showHideLayers() { 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) { xPos=findPosX(document.getElementById(obj.id+"_img")); yPos=findPosY(document.getElementById(obj.id+"_img")); obj=obj.style; v=(v=='show')?'visible' v=='hide')?'hidden':v; } obj.left=parseInt(xPos)+14; obj.top=parseInt(yPos)+14; obj.visibility=v; } } findXPos() and findYPos() is correctly working .. i have tested it mouse events are also running ok. Adnan Memon
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
run a few tests: place an alert after the function function MM_showHideLayers() { alert('test'); and see if the function is being called. if that works add an alert after obj.visibility=v; to see what the value is in v alert(v); see if it is showing stuff correctly Eric
|
 |
 |
|
|
subject: Hiding Relatively Positioned Layer
|
|
|