后来发展到其文字内容可以增、删、编、改,即可以编辑:
运行代码框
<html>
<head>
<title>EditSelect</title>
<script>
function isIE(){
a=navigator.appVersion.split(";")
b=a[1].split(" ")
return parseFloat(b[2])
}
if (isIE()<5.5)
{
scHTML=’<div id="selectcontent" class="selectdiv" style="visibility:hidden;"><!----><div id="selecthtml" class="selectcontent">selectáD表</div></div>’
}
else
{
scHTML=’<div id="selectcontent" class="selectdiv" style="visibility:hidden;"><div id="selecthtml" class="selectcontent">selectáD表</div></div>’
}
document.write(scHTML)
vDiv=selectcontent
vDivHtml=selecthtml
function editselect(name,size,defaulttext,width,height,readonly){
var combo=this;
this.options=new Array();
this.oj=new Array();
this.name=name;
this.divname=name+’_div’;
this.buttonname=name+’_button’;
this.tablename=name+’_table’;
this.htmltable=name+’_html’
if (!height) this.height=0; else this.height=height
if (width) this.width=width
if (!size) size=8
if (!defaulttext) defaulttext=""
if (!readonly || readonly==0) {readonly="" }else {if (readonly==1) readonly="readonly style=cursor:default";this.readonly=1}
esHTML=’<div id=’+this.divname+’>’
+’<table id=’+this.tablename+’ cellpadding=0 cellspacing=0 class=select><tr><td bgcolor=#FFFFFF>’
+’<input type=text class=selecttext size="’+size+’" name=’+name+’ value="’+defaulttext+’" ’+readonly+’><td><button class=selectbutton id=’+this.buttonname+’>6</td></tr></table>’
+’</div>’
document.write(esHTML)
this.sbutton=eval("document.all."+this.buttonname)
if (this.readonly==1) eval("document.all."+this.name).onclick=function(){combo.show()}
this.sbutton.onclick=function(){combo.show()}
this.show=function(){
pDiv=eval(combo.divname)
pTable=eval(combo.tablename)
var vHTML=’<table id=htmltable cellspacing="0" cellpadding="2" bgcolor="#ffffff" class="selecttable" width=100%>’
for (i=0;i<combo.options.length;i++)
{
vHTML+=’<tr onmouseover="mo(this)" onmouseout="mu(this)" onclick="document.all.’+combo.name+’.value=this.innerText;selectcontent.style.visibility=\’hidden\’;’+combo.oj[i]+’"><td nowrap>’+combo.options[i]
}
vHTML+="</table>"
vDivHtml.innerHTML=vHTML
vtop=pDiv.offsetTop+pDiv.offsetHeight
vleft=pDiv.offsetLeft+2
vParent = pDiv.offsetParent;
while (vParent.tagName.toUpperCase() != "BODY")
{
vleft += vParent.offsetLeft;
vtop += vParent.offsetTop;
vParent = vParent.offsetParent;
}
var redge=document.body.clientWidth-vleft
var bedge=document.body.clientHeight-vtop
if (!combo.width) {vDiv.style.width=pTable.offsetWidth} else {vDiv.style.width=combo.width}
if (combo.height==0)
{
vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
}
else
{
if (htmltable.offsetHeight>combo.height)
{
vDiv.style.pixelHeight=combo.height
vDivHtml.style.pixelHeight=combo.height
}
else
{
vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
}
}
vDivHtml.scrollTop=0
if (redge<vDiv.offsetWidth)
vDiv.style.left=vleft-1-(vDiv.offsetWidth-redge)
else
vDiv.style.left=vleft-1
if (bedge<vDiv.offsetHeight)
//vDiv.style.top=vtop-vDiv.offsetHeight-pDiv.offsetHeight
vDiv.style.top=vtop-vDiv.offsetHeight+bedge
else
vDiv.style.top=vtop
vDivHtml.style.width=parseInt(vDiv.style.width)
vDiv.style.visibility="visible"
}
this.add=function(text,js){
combo.options[combo.options.length]=text
combo.oj[combo.oj.length]=js
}
this.clearall=function(){
combo.options=new Array()
}
this.about=function(){
}
}
function mo(obj){
obj.style.backgroundColor="#000099"
obj.style.color="#ffffff"
}
function mu(obj){
obj.style.backgroundColor=""
obj.style.color="#000000"
}
document.onmousedown=function(){
if (vDiv.style.visibility=="visible"){
mx=event.x + document.body.scrollLeft
my=event.y + document.body.scrollTop;
x1=vDiv.offsetLeft
y1=vDiv.offsetTop
x2=vDiv.offsetLeft+vDiv.offsetWidth
y2=vDiv.offsetTop+vDiv.offsetHeight
if (mx<x1 || my<y1 || x2<mx || y2<my)
{
vDiv.style.visibility=’hidden’
}
}
}</script>
<style>
.selecttext{
border:0px
height: 16;
font-family:arial;
font-size:12px;
}
.selectbutton{
font-family:webdings;
font-size:10px;
height: 19;
width: 16;
border:1px solid #83A5EB;
line-height:0px;
padding-bottom:3px;
background-color:#D1E0FD
}
.selecttable{
font-family:arial;
font-size:12px;
cursor:default;
}
.selectcontent
{
position: absolute;
top:0;
left:0;
overflow:auto;
border:1px solid #000000
}
.selectdiv
{
position: absolute;
width:100;
overflow:hidden;
}
.select{
border-collapse: collapse;
border:1px solid #7F9DB9
}
</style>
</head>
<body bgcolor="#83A5EB" background="http://moodboy.com/puterjam/blog/attachments/month_0408/oldr_cs1.JPG">
<table border="0" width="100%">
<tr>
<td width="151" align="center"><font size="2">可编辑的Select</font></td>
<td><script>
var sel1=new editselect("select1","25","可编辑的Select","");
sel1.add("这是一个可以编辑的Select")
sel1.add("支持CSS")
sel1.add("可以通过CSS,修改外形")
sel1.add("突破原来的Select诸多限制")
</script></td>
</tr>
<tr>
<td width="151" align="center"><font size="2">长度可以随意修改
可以设置为只读</font></td>
<td>
<script>
var sel2=new editselect("select2","20","长度可以随意修改",250,82,1);
sel2.add("这是一个可以编辑的Select")
sel2.add("支持CSS")
sel2.add("可以通过CSS,修改外形")
sel2.add("作者:舜子制作")
sel2.add("MSN:puterjam@msn.com")
</script>
</td>
</tr>
<tr>
<td width="151" align="center"><font size="2">可以遮盖系统Select</font></td>
<td>
<script>
var sel3=new editselect("select3","25","可以遮盖系统Select","",41);
sel3.add("这是一个可以编辑的Select")
sel3.add("支持CSS")
sel3.add("可以通过CSS,修改外形")
sel3.add("突破原来的Select诸多限制")
</script>
</td>
</tr>
<tr>
<td width="151" align="right"> </td>
<td><select><option>系统的Select</option></select> </td>
</tr>
</table>
</body>
</html>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
可编辑的select:
运行代码框
按回车键输入新内容,按DEL删除选中内容<br>
<body bgcolor="#fef4d9" onload="s1.focus();">
<script language="JavaScript">
<!--
function catch_keydown(sel)
{
switch(event.keyCode)
{
case 13:
//Enter;
sel.options[sel.length] = new Option("","",false,true);
event.returnValue = false;
break;
case 27:
//Esc;
alert("text:" + sel.options[sel.selectedIndex].text + ", value:" + sel.options[sel.selectedIndex].value + ";");
event.returnValue = false;
break;
case 46:
//Delete;
if(confirm("删除当前选项!?"))
{
sel.options[sel.selectedIndex] = null;
if(sel.length>0)
{
sel.options[0].selected = true;
}
}
event.returnValue = false;
break;
case 8:
//Back Space;
var s = sel.options[sel.selectedIndex].text;
sel.options[sel.selectedIndex].text = s.substr(0,s.length-1);
event.returnValue = false;
break;
}
}
function catch_press(sel)
{
sel.options[sel.selectedIndex].text = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
event.returnValue = false;
}
//-->
</script>
<select name=s1 onkeydown="catch_keydown(this);" onkeypress="catch_press(this);" style="font-size:12px;"><option>---</option></select>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
运行代码框
<SCRIPT LANGUAGE="Javascript">
function inputToSelect(text,value)
{
i=0;
while(document.all.sel.options[i])
{
if(document.all.sel.options[i].text == text)
return 0;
i++;
}
var oOption = document.createElement("OPTION");
oOption.text=text;
oOption.value=value;
document.all.sel.add(oOption);
}
</SCRIPT>
<input name="inputx" value="请选择或输入相应内容" onclick="if(this.value==’请选择或输入
相应内容’){this.value=’’;}else{}" style="border-left:1px solid #000000;border-top:1px solid #000000;border-bottom:1px solid #000000;border-
right:0px solid #000000;width:134;height:22px;" autocomplete="off">
<select id="sel" style="width:150;margin-left:-134;border:1px solid #000000;border-left:0px;height:22px;"
onChange="inputx.value=value" onClick="inputToSelect(inputx.value,inputx.value)">
<option value="111111111">111111111</option>
<option value="汉字也可以">汉字也可以</option>
</select>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
为了让select里有更多的图片、css修饰及其他静、动态修饰效果,而select本身优先级别太高,其修饰效果很少且不能满足上述要求,遂涌现出很多模拟的select:
运行代码框
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<style type="text/css">
<!--
.n1 {
border-right: 1px none #999999;
border-top: 1px solid #999999;
border-bottom: 1px solid #DBDBDB;
border-left: 1px solid #999999;
cursor: default;
width:80px
}
.n2 {
background: url(http://www.blueidea.com/bbs/images/oicq.gif) no-repeat center center;
border-top: 1px solid #999999;
border-right: 1px solid #999999;
border-bottom: 1px solid #DBDBDB;
border-left: 1px none;
width: 18px;
cursor: default;
}
.ss {
color: #FFFFFF;
background: #0A246A;
}
-->
</style>
<script lanuage="JScript">
function turnit(ss)
{
if (ss.style.display=="none")
{ss.style.display="";
for (var i=1;i<4;i++)
{
if (eval(’t’+i).innerText==text1.value)
eval(’t’+i).className=’ss’
else
eval(’t’+i).className=’’
}
}
else
{ss.style.display="none";
}
}
function sele(tid)
{
bb.style.display=’none’;
text1.value=tid.innerText;
}
function over(tid)
{
for (var i=1;i<4;i++)
{
eval(’t’+i).className=’’
}
tid.className=’ss’
if(typeof(prevObj)!=’undefined’)
prevObj.bgColor=’’;
prevObj=tid;
}
function openb()
{
if (bb.style.display==’’)
bb.style.display=’none’
}
</script>
<style type="text/css">
<!--
table {
font-size: 9pt;
}
-->
</style>
</head>
<body onclick=if(event.srcElement.tagName==’BODY’)bb.style.display=’none’;>
<table width="98" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="98" nowrap>
<input name="text1" type="text" size="10" class=n1 readonly value=请选择 onclick=turnit(bb) onSelectStart=event.returnValue=false><input name="Submit" type="text" class="n2" value="" readonly onclick=turnit(bb)>
</td>
</tr>
<tr>
<td id=bb style=display:none><div id="Layer1" style="position:absolute; width:98px; height:100px; overflow: scroll; overflow-x:hidden; z-index: 1;" class="n1">
<table width="100%" border="0" cellpadding="0" cellspacing="0" id=tb onSelectStart=event.returnValue=false>
<tr>
<td id=t1 onMouseOver =over(this) onclick=sele(this)>选择1</td>
</tr>
<tr>
<td id=t2 onMouseOver =over(this) onclick=sele(this)>选择2</td>
</tr>
<tr>
<td id=t3 onMouseOver =over(this) onclick=sele(this)>选择3</td>
</tr>
</table>
</div></td>
</tr>
</table>
</body>
</html>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
运行代码框
<center><sup><font face="隶书" color="blue">上标是不是这个?</font></sup><font size="6" face="华文行楷" color="red">如果要想以其他的文字作为上标该怎么做啊?</font><sub><font face="黑体" color="green"><b><i>下标是不是这个?</b></i></font></sub>
<br><br>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
下面这两个已达到较高的水准(动态内容):
运行代码框
<html>
<head>
<title>EditSelect</title>
<script>
scHTML=’<div id="selectcontent" class="selectdiv" style="visibility:hidden;"><div id="selecthtml" class="selectcontent">selectÁбí</div></div>’
document.write(scHTML)
vDiv=selectcontent
vDivHtml=selecthtml
function editselect(name,size,defaulttext,width,height,readonly){
var combo=this;
this.options=new Array();
this.name=name;
this.divname=name+’_div’;
this.buttonname=name+’_button’;
this.tablename=name+’_table’;
this.htmltable=name+’_html’
if (!height) this.height=0; else this.height=height
if (width) this.width=width
if (!size) size=8
if (!defaulttext) defaulttext=""
if (!readonly || readonly==0) {readonly="" }else {if (readonly==1) readonly="readonly style=cursor:default";this.readonly=1}
esHTML=’<div id=’+this.divname+’>’
+’<table id=’+this.tablename+’ cellpadding=0 cellspacing=0 class=select><tr><td bgcolor=#FFFFFF>’
+’<textarea type=text class=selecttext cols="’+size+’" rows="1" name=’+name+’ value="’+defaulttext+’" contenteditable="false" ’+readonly+’></textarea><td><button class=selectbutton id=’+this.buttonname+’>6</td></tr></table>’
+’</div>’
document.write(esHTML)
this.sbutton=eval("document.all."+this.buttonname)
if (this.readonly==1) eval(this.name).onclick=function(){combo.show()}
this.sbutton.onclick=function(){combo.show()}
this.show=function(){
pDiv=eval(combo.divname)
pTable=eval(combo.tablename)
var vHTML=’<table id=htmltable cellspacing="0" cellpadding="2" bgcolor="#ffffff" class="selecttable" width=100%>’
for (i=0;i<combo.options.length;i++)
{
vHTML+=’<tr onmouseover="mo(this)" onmouseout="mu(this)" onclick="document.all.’+combo.name+’.innerHTML=\’\’;var t=document.createElement(\’span\’);t.innerHTML=this.innerHTML;document.all.’+combo.name+’.appendChild(t);selectcontent.style.visibility=\’hidden\’"><td nowrap>’+combo.options[i]
}
vHTML+="</table>"
vDivHtml.innerHTML=vHTML
vtop=pDiv.offsetTop+pDiv.offsetHeight
vleft=pDiv.offsetLeft+1
vParent = pDiv.offsetParent;
while (vParent.tagName.toUpperCase() != "BODY")
{
vleft += vParent.offsetLeft;
vtop += vParent.offsetTop;
vParent = vParent.offsetParent;
}
var redge=document.body.clientWidth-vleft
var bedge=document.body.clientHeight-vtop
if (!combo.width) {vDiv.style.width=pTable.offsetWidth} else {vDiv.style.width=combo.width}
if (combo.height==0)
{
vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
}
else
{
if (htmltable.offsetHeight>combo.height)
{
vDiv.style.pixelHeight=combo.height
vDivHtml.style.pixelHeight=combo.height
}
else
{
vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
}
}
vDivHtml.scrollTop=0
if (redge<vDiv.offsetWidth)
vDiv.style.left=vleft-1-(vDiv.offsetWidth-redge)
else
vDiv.style.left=vleft-1
if (bedge<vDiv.offsetHeight)
//vDiv.style.top=vtop-vDiv.offsetHeight-pDiv.offsetHeight
vDiv.style.top=vtop-vDiv.offsetHeight+bedge
else
vDiv.style.top=vtop
vDivHtml.style.width=parseInt(vDiv.style.width)
vDiv.style.visibility="visible"
}
this.add=function(text){
combo.options[combo.options.length]=text
}
this.about=function(){
}
}
function mo(obj){
obj.style.backgroundColor="#000099"
obj.style.color="#ffffff"
}
function mu(obj){
obj.style.backgroundColor=""
obj.style.color="#000000"
}
document.onmousedown=function(){
if (vDiv.style.visibility=="visible"){
mx=event.x + document.body.scrollLeft
my=event.y + document.body.scrollTop;
x1=vDiv.offsetLeft
y1=vDiv.offsetTop
x2=vDiv.offsetLeft+vDiv.offsetWidth
y2=vDiv.offsetTop+vDiv.offsetHeight
if (mx<x1 || my<y1 || x2<mx || y2<my)
{
vDiv.style.visibility=’hidden’
}
}
}
</script>
<style>
.selecttext{
border:0px
height: 22;
font-family:arial;
font-size:14px;
overflow:hidden;
}
.selectbutton{
font-family:webdings;
font-size:10px;
height: 25;
width: 16;
border:1px solid #83A5EB;
line-height:0px;
padding-bottom:1px;
background-color:#D1E0FD
}
.selecttable{
font-family:arial;
font-size:12px;
cursor:default;
}
.selectcontent
{
position: absolute;
top:0;
left:0;
overflow:auto;
border:1px solid #000000
}
.selectdiv
{
position: absolute;
width:100;
overflow:hidden;
}
.select{
border-collapse: collapse;
border:1px solid #7F9DB9
}
</style>
</head>
<body bgcolor="#83A5EB" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<center>
<table border="0" width="234">
<tr>
<td width="151" align="center"><font size="2">可编辑的Select</font></td>
<td><script>
var sel1=new editselect("select1","25","可编辑的Select","");
sel1.add("<marquee behavior=alternate><img src=’http://www.blueidea.com/articleimg/bbsimg/icon6.gif’ align=’absmiddle’> <B><font color=#22FF22>知</font><font color=#FF2222>往</font><font color=#001199>观</font><font color=#00fffa>来</font></B></marquee>")
sel1.add("<img src=’http://www.blueidea.com/articleimg/bbsimg/icon7.gif’ align=’absmiddle’> 微风香水")
sel1.add("<img src=’http://www.blueidea.com/articleimg/bbsimg/icon8.gif’ align=’absmiddle’> 阳光锈了")
sel1.add("<img src=’http://www.blueidea.com/articleimg/bbsimg/icon9.gif’ align=’absmiddle’> <B><font color=#22FF22>观</font><font color=#FF2222>往</font><font color=#001199>知</font><font color=#00fffa>来</font></B>")
</script></td>
</tr>
<tr>
<td width="151" align="right"> </td>
<td> </td>
</tr>
</table>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
运行代码框
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<style type="text/css">
<!--
.n1 {
border-right: 1px none #999999;
border-top: 1px solid #999999;
border-bottom: 1px solid #DBDBDB;
border-left: 1px solid #999999;
cursor: default;
width:180px
}
.n2 {
background: url(http://www.blueidea.com/bbs/images/newwin.gif) no-repeat center center;
border-top: 1px solid #999999;
border-right: 1px solid #999999;
border-bottom: 1px solid #DBDBDB;
border-left: 1px none;
width: 18px;
cursor: default;
}
.ss {
color: #FFFFFF;
background: #0A246A;
}
-->
</style>
<script lanuage="JScript">
function turnit(ss)
{
if (ss.style.display=="none")
{ss.style.display="";
}
else
{ss.style.display="none";
}
}
function sele(tid)
{
bb.style.display=’none’;
text1.value=tid.innerText;
}
function over(tid)
{
for (var i=1;i<4;i++)
{
eval(’t’+i).className=’’
}
tid.className=’ss’
}
function out(tid)
{
if (bb.style.display!=’none’)
tid.className=’’
}
</script>
<style type="text/css">
<!--
table {
font-size: 16pt;font-family:华文行楷;
}
-->
</style>
</head>
<body style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=green,endColorStr=white);SCROLLBAR-ARROW-COLOR: #fc0048;
SCROLLBAR-TRACK-COLOR: #242400;
SCROLLBAR-BASE-COLOR: #24b400;">
<table width="198" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="198" nowrap>
<input name="text1" type="text" size="20" class=n1 readonly value=这里头别无选择 onclick=turnit(bb) style="color:red;font-family:隶书;font-size:14px;text-align:center;background:yellow;"><input name="Submit" type="text" class="n2" value="" readonly onclick=turnit(bb)>
</td>
</tr>
<tr>
<td id=bb style=display:none><div id="Layer1" style="position:absolute; width:198px; height:100px; overflow: scroll; overflow-x:hidden; z-index: 1;SCROLLBAR-ARROW-COLOR: #fc0048;
SCROLLBAR-TRACK-COLOR: #242400;
SCROLLBAR-BASE-COLOR: #24b400;" class="n1" >
<table width="100%" border="0" cellpadding="0" cellspacing="0" id=tb>
<tr>
<td id=t1 onMouseOver =over(this) onMouseOut =out(this) onclick=sele(this) style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=lime,endColorStr=white);"><img src="http://www.blueidea.com/articleimg/usericon/hubro.gif" align="absmiddle">金翅擘海</td>
</tr>
<tr>
<td id=t2 onMouseOver =over(this) onMouseOut =out(this) onclick=sele(this) style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=brown,endColorStr=white);"><img src="http://www.blueidea.com/articleimg/usericon/hubro.gif" align="absmiddle"><B><font color="#22FF22">知</font><font color="#FF2222">往</font><font color="#001199">观</font><font color="#00fffa">来</font></B></td>
</tr>
<tr>
<td id=t3 onMouseOver =over(this) onMouseOut =out(this) onclick=sele(this) style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=darckblue,endColorStr=white);"><marquee behavior="alternate"><img src="http://www.blueidea.com/articleimg/usericon/hubro.gif" align="absmiddle">海阿洛瓦</marquee></td>
</tr>
<tr>
<td id=t1 onMouseOver =over(this) onMouseOut =out(this) onclick=sele(this) style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=pink,endColorStr=white);"><img src="http://www.blueidea.com/articleimg/usericon/hubro.gif" align="absmiddle">蓝色月光</td>
</tr>
<tr>
<td id=t2 onMouseOver =over(this) onMouseOut =out(this) onclick=sele(this) style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=red,endColorStr=white);"><img src="http://www.blueidea.com/articleimg/usericon/hubro.gif" align="absmiddle"><B><font color="#22FF22">波</font><font color="#FFdd22">希</font><font color="#001199">米</font><font color="#00fffa">亚 </font></B></td>
</tr>
<tr>
<td id=t3 onMouseOver =over(this) onMouseOut =out(this) onclick=sele(this) style="FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=green,endColorStr=white);"><marquee behavior="alternate"><img src="http://www.blueidea.com/articleimg/usericon/hubro.gif" align="absmiddle">红色黑客</marquee></td>
</tr>
</table>
</div></td>
</tr>
</table>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
可以去掉下拉的小三角,但不可以无边框:
运行代码框
<script>
function myjump(myObj){
myurl=myObj.options[myObj.selectedIndex].value;
window.open(myurl,"newwin","width=300,height=200");
}
</script>
<center>
<select name="menu1" size=3 onChange="myjump(menu1)" style="background-color:
#CCCCFF; color:#0000FF">
<option selected>文字链接</option>
<option value="http://www.bineon.com/bbs/">霓虹论坛</option>
<option value="http://www.ylqh.com">叶落秋寒</option>
</select>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
鼠标移过来select自动下拉:
运行代码框
<style>
<!--
td{font-size:12px; }
body{margin:0px; line-height:20px}
a:link { color:#000000; text-decoration:none}
a:visited {color:#000000; text-decoration:none}
a:hover { color:#FFFFFF; background-color:#003366; text-decoration:none}
a:active {color:#FFFFFF; text-decoration:none}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
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; }
}
//-->
</script>
<div id="Layer1" style="position:absolute; left:0px; top:0px; width:145px; height:20px; z-index:1; visibility: visible; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000;" onMouseMove="MM_showHideLayers(’l2’,’’,’show’)" onMouseOut="MM_showHideLayers(’l2’,’’,’hide’)"></div>
<div>
<select name="select">
<option selected>鼠标移过来自动下拉</option>
<option selected>鼠标移过来自动下拉</option>
</select>
<div id="l2" style="position:absolute; left:0px; top:20px; width:142px; border:1px solid #000;visibility: hidden; height: 80px; z-index: 2;" onMouseMove="MM_showHideLayers(’l2’,’’,’show’)" onMouseOut="MM_showHideLayers(’l2’,’’,’hide’)" onClick="MM_showHideLayers(’l2’,’’,’hide’)">
<table width="100%" height="80" border="0" cellpadding="0" cellspacing="0">
<tr>
<td onMouseOver="this.style.backgroundColor=’#003366’;this.style.color=’#ffffff’" onMouseOut="this.style.backgroundColor=’#FFFFFF’;this.style.color=’#000000’" onClick="window.open(’http://www.blueidea.com’)" >蓝色月光</td>
</tr>
<tr>
<td onMouseOver="this.style.backgroundColor=’#003366’;this.style.color=’#ffffff’" onMouseOut="this.style.backgroundColor=’#FFFFFF’;this.style.color=’#000000’" onClick="window.open(’http://www.blueidea.com’)" >红色黑客</td>
</tr>
<tr>
<td onMouseOver="this.style.backgroundColor=’#003366’;this.style.color=’#ffffff’" onMouseOut="this.style.backgroundColor=’#FFFFFF’;this.style.color=’#000000’" onClick="window.open(’http://www.blueidea.com’)" >
<marquee behavior="alternate"><B><font color="#22FF22">知</font><font color="#FF2222">往</font><font color="#001199">观</font><font color="#00fffa">来</font></B></marquee>
</td>
</tr>
<tr>
<td onMouseOver="this.style.backgroundColor=’#003366’;this.style.color=’#ffffff’" onMouseOut="this.style.backgroundColor=’#FFFFFF’;this.style.color=’#000000’" onClick="window.open(’http://www.blueidea.com’)" >
<script language="javascript">
var pltsPop=null;
var pltsoffsetX = 10;
var pltsoffsetY = 15;
var pltsPopbg="#ffffee";
var pltsPopfg="#111111";
var pltsTitle="";
document.write(’<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>’);
function pltsinits()
{
document.onmouseover = plts;
document.onmousemove = moveToMouseLoc;
}
function plts()
{ var o=event.srcElement;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
pltsPop=o.dypop;
if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
{
pltsTipLayer.style.left=-1000;
pltsTipLayer.style.display=’’;
var Msg=pltsPop.replace(/\n/g,"<br>");
Msg=Msg.replace(/\0x13/g,"<br>");
var re=/\{(.[^\{]*)\}/ig;
if(!re.test(Msg))pltsTitle="Sheneyan";
else{
re=/\{(.[^\{]*)\}(.*)/ig;
pltsTitle=Msg.replace(re,"$1")+" ";
re=/\{(.[^\{]*)\}/ig;
Msg=Msg.replace(re,"");
Msg=Msg.replace("<br>","");}
var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");
var content =
’<table style="FILTER:alpha(opacity=80) shadow(color=#bbbbbb,direction=150);" id=toolTipTalbe border=0><tr><td width="100%"><table class=selet_bg cellspacing="0" cellpadding="0" style="width:100%" style="font size:9pt;">’+
’<tr id=pltsPoptop><th height=12 valign=bottom class=header><p id=topleft align=left>↖’+pltsTitle+’</p><p id=topright align=right style="display:none">’+pltsTitle+’↗</font></th></tr>’+
’<tr><td "+attr+" class=f_one style="padding-left:10px;padding-right:10px;padding-top: 4px;padding-bottom:4px;line-height:135%">’+Msg+’</td></tr>’+
’<tr id=pltsPopbot style="display:none"><th height=12 valign=bottom class=header><p id=botleft align=left>↙’+pltsTitle+’</p><p id=botright align=right style="display:none">’+pltsTitle+’↘</font></th></tr>’+
’</table></td></tr></table>’;
pltsTipLayer.innerHTML=content;
toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);
moveToMouseLoc();
return true;
}
else
{
pltsTipLayer.innerHTML=’’;
pltsTipLayer.style.display=’none’;
return true;
}
}
function moveToMouseLoc()
{
if(pltsTipLayer.innerHTML==’’)return true;
var MouseX=event.x;
var MouseY=event.y;
//window.status=event.y;
var popHeight=pltsTipLayer.clientHeight;
var popWidth=pltsTipLayer.clientWidth;
if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)
{
popTopAdjust=-popHeight-pltsoffsetY*1.5;
pltsPoptop.style.display="none";
pltsPopbot.style.display="";
}
else
{
popTopAdjust=0;
pltsPoptop.style.display="";
pltsPopbot.style.display="none";
}
if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth)
{
popLeftAdjust=-popWidth-pltsoffsetX*2;
topleft.style.display="none";
botleft.style.display="none";
topright.style.display="";
botright.style.display="";
}
else
{
popLeftAdjust=0;
topleft.style.display="";
botleft.style.display="";
topright.style.display="none";
botright.style.display="none";
}
pltsTipLayer.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust;
pltsTipLayer.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust;
return true;
}
pltsinits();
</script>
<img border="0" alt="<img border=’0’ src=’http://pic1.blueidea.com/bbs/icon7.gif’>" src="http://www.blueidea.com/articleimg/usericon/sheneyan.gif">
