Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding layer on body focus 1

Status
Not open for further replies.

Streetdaddy

Programmer
Jun 10, 1999
161
AU
Is it possible to hide a layer when with an onClick parameter in the body tag?

reason being, i have layers that show on a img mouseOver, but I dont want them to hide on the img mouseOut, but to hide on body onFocus

X-) Miles
vmiles@senet.com.au
 
It isn't truely an onclick, instead it is an onFocus and here is something what it would look like

<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot;>
<!--
function findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf(&quot;?&quot;))>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[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers.document); return x;
}

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

<BODY onFocus=&quot;showHideLayers('Layer1','','hide')&quot;>
<div id=&quot;Layer1&quot; style=&quot;position:absolute; left:244px; top:223px; width:112px; height:121px; z-index:1&quot;>TEST</div>
<a href=&quot;#&quot; onClick=&quot;showHideLayers('Layer1','','show')&quot;>TEST</a>
</body>

Clicking TEST in the webpage will display a layer and if you click anywhere else in the body it will hide the layer.

The only problem with this is if they switch to a different window (Alt+tab) and come back to the webpage it will hide the layers that are currently being displayed.

Hope This helps.
 
I think that will do just fine :)

if they alt tab to another window, too bad!

thanks ;) Miles
vmiles@senet.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top