problemer med DHTML menu
Jeg vil gerne lave et dropdown søgefelt i en horizontal menu. Men jeg kan kun få det til at virke ved at bruge "position: absolute". Det er jo ikke så fedt - da dropdown'en så ikke følger menuen hvis jeg ændre størrelsen på mit browser vindue.HJÆLP !!!
html kode:
--------------------------
<script language="JavaScript"><!--
//names of dropdowns stored here
f7_droplayer=new Array()
f7_droplayer[0]="drop1"
//simple browser check
f7_v4=(parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<=5)?1:0
f7_ie=(document.all && f7_v4)?1:0
f7_ns=(document.layers && f7_v4)?1:0
//code for drops
function f7_showdrop(thelayer){
f7_keep=thelayer; f7_hideall(); f7_showitnow=1
f7_showit(thelayer)
}
function f7_showit(thelayer){
if(f7_ie){
eval(f7_droplayer[thelayer]+'.style.visibility="visible"') ;
eval(f7_droplayer[thelayer]+'.style.display="inline"') ;
//alert(eval(f7_droplayer[thelayer]+'.style.display'));
}
if(f7_ns){ eval('document.'+f7_droplayer[thelayer]+'.visibility="show"');}
}
function f7_hidedrop(){
f7_keep=-1; setTimeout('f7_hideall()',500)
}
f7_keep=-1
function f7_hideall(){
for(i=0;i<f7_droplayer.length;i++){
f7_hideit=0; f7_checkmousepos(i)
if(f7_ie && f7_keep!=i){
if(f7_hideit){
eval(f7_droplayer[i]+'.style.visibility="hidden"') ;
eval(f7_droplayer[i]+'.style.display="none"') ;
}
}
if(f7_ns && f7_keep!=i){
if(f7_hideit){ eval('document.'+f7_droplayer[i]+'.visibility="hide"') }
}
}
}
//deal with cursor over layer
document.onmousemove = f7_getmousepos
if (f7_ns) document.captureEvents(Event.MOUSEMOVE)
function f7_getmousepos(e){
if(f7_ns){f7_mousex=e.pageX; f7_mousey=e.pageY}
if(f7_ie){f7_mousex=event.clientX; f7_mousey=event.clientY;}
}
function f7_checkmousepos(i){
if(f7_ns){
f7_x_min=eval('document.'+f7_droplayer[i]+'.left')
f7_x_max=f7_x_min+eval('document.'+f7_droplayer[i]+'.clip.width')
f7_y_min=eval('document.'+f7_droplayer[i]+'.top')
f7_y_max=f7_y_min+eval('document.'+f7_droplayer[i]+'.clip.height')
}
if(f7_ie){
f7_x_min=eval(f7_droplayer[i]+'.style.pixelLeft')
f7_x_max=f7_x_min+eval(f7_droplayer[i]+'.style.pixelWidth')
f7_y_min=eval(f7_droplayer[i]+'.style.pixelTop')
f7_y_max=f7_y_min+eval(f7_droplayer[i]+'.style.pixelHeight')
}
if (f7_mousex>=f7_x_min && f7_mousex<=f7_x_max && f7_mousey>=f7_y_min && f7_mousey<=f7_y_max){
f7_hideit=0; setTimeout('f7_hideall()',500)
}
else { f7_hideit=1 }
return f7_hideit
}
//--></script>
<style type="text/css">
<!--
.dropdown { position: absolute;
color:black;
width:140px;
border: #000000;
border-style: solid;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
background-color: #ffffff;
layer-background-color: #ffffff;
left:320px;
top:33px;
display:none;
z-index:1;
visibility: hidden ;}
.drophead {
color : #FFFFFF;
font-size : 8pt;
font-family : Arial;
text-decoration : none;
}
.dropitem { text-decoration:none;
color:yellow;
font:12px Arial, Verdana, Helvetica, sans-serif;}
.drophead:hover { color:red; text-decoration:none }
.dropitem:hover { color:yellow; font: bold }
-->
</style>
<div id="drop1" class="dropdown" onmouseover="f7_showdrop(0)" onmouseout="f7_hidedrop()">
<FORM action="" method=POST id=form1 name=form1>
<INPUT type=text id=text1 name=text1>
<br>
<INPUT type=submit id=submit1 name=submit1>
</FORM>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<TR>
<TD bgcolor=#aaaaaa VALIGN=Top width=420>
<a href="#">Debat</a>
<a href="#">Produkter</a>
</td>
<td nowrap VALIGN=Top width=50 bgcolor="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr >
<td valign="top">
<IMG SRC="http://www.golfonline.dk/images/spacer.gif" width="1" height="15" alt="" border="0">
<IMG SRC="http://www.golfonline.dk/images/top_bullets.gif" width=2 height=9 border=0 alt="" hspace=0>
<a href="#" class="drophead" onmouseover="f7_showdrop(0)"
onmouseout="f7_hidedrop()">Søg</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
------------------------------
