1. 程式人生 > >CSS中嵌入指令碼+DIV下拉列表

CSS中嵌入指令碼+DIV下拉列表

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>Pconcool's Blog</title>
<style>
<!--
BODY 
{
    background-color
: #ffffff;
    SCROLLBAR-FACE-COLOR
: #ededed;
    SCROLLBAR-HIGHLIGHT-COLOR
: #fafafa;
    SCROLLBAR-SHADOW-COLOR
: #666666;
    SCROLLBAR-3DLIGHT-COLOR
: #ffffff;
    SCROLLBAR-ARROW-COLOR
: #777777;
    SCROLLBAR-TRACK-COLOR
: #fcfcfc;
    SCROLLBAR-DARKSHADOW-COLOR
: #ffffff;
}

A:link 
{
    COLOR
: #333333; TEXT-DECORATION: none;line-height: 180%
}

A:visited 
{
    COLOR
: #333333; TEXT-DECORATION: none;line-height:
 180%
}

A:hover 
{
    COLOR
: #DF4F00; TEXT-DECORATION: none;line-height: 180%
}

A:active 
{
    COLOR
: #D41E00; TEXT-DECORATION: none;line-height: 180%
}

body,td
{font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif;}
#Layer1 
{
    position
:absolute;
    border
:1px solid #1556B1;
    background
:#EFF7FF;
    color
:#073E8B;
    padding
:3 4;
    width
:200px;
    height
:120px;
    z-index
:1;
    left
: 30px;
    top
: 90px;
    overflow
:auto;
    table-layout
:fixed;
}

input
{border:1px solid #808080; background:#fcfcfc; width:200px; height:20px;}
.ajaxtd
{cursor:hand; color:#073E8B; white-space:nowrap;}
.onmouse
{
    event
:expression(
        onmouseover = function(){
            this.style.backgroundColor='#F8FDFF'
;
            this.style.color='#8B0E07';
        
}
,
        onmouseout = function()
{
            this.style.backgroundColor='#EFF7FF';
            this.style.color='#073E8B';
        
}

    )
}
-->
</style>
<script language="javascript">
    
function showdiv(obj,txt){
    
var t,l,tn;
    
var e=document.getElementById(txt)
    document.getElementById(obj).style.display
="";
    l
=e.offsetLeft;
    t
=e.offsetTop;
    
while(e = e.offsetParent)
        tn 
= e.tagName.toUpperCase();
        
        t 
+= e.offsetTop - (tn =="DIV"&&e.scrollTop?e.scrollTop:0); 
        l 
+= e.offsetLeft - (tn =="DIV"&&e.scrollLeft?e.scrollLeft:0); 
    }

    document.getElementById(obj).style.left
=l;
    document.getElementById(obj).style.top
=t+21;
    document.getElementById(obj).style.width
=e.offsetWidth;
    document.getElementById(obj).style.height
=e.offsetHeight
    }

    
function hidediv(obj){
        document.getElementById(obj).style.display
="none";
    }

    
function gettdvalue(obj){
        document.getElementById(
"txt2").value=document.getElementById(obj).innerText;
    }

</script>
</head>

<body onFocus="hidediv('Layer1')">
<input name="txt2" type="text" id="txt2" onFocus="showdiv('Layer1','txt2')"/>
<div id="Layer1" style="display:none;" onDblClick="hidediv('Layer1')">
    
<table cellpadding="2" cellspacing="0" border="0" width="100%">
        
<tr>
            
<td class="ajaxtd onmouse" onclick="gettdvalue('td1')" id="td1">中國優優網</td>
        
</tr>
        
<tr>
            
<td class="ajaxtd onmouse" onclick="gettdvalue('td2')" id="td2">Http://www.chinauuw.com</td>
        
</tr>
        
<tr>
            
<td class="ajaxtd onmouse" onclick="gettdvalue('td3')" id="td3">Pconcol's Blog</td>
        
</tr>
        
<tr>
            
<td class="ajaxtd onmouse" onclick="gettdvalue('td4')" id="td4">ttp://www.pconcool.com</td>
        
</tr>
    
</table>
</div>
</body>
</html>