再次求助JS高人,连同上贴共赠200分
我上个帖子的地址:
http://community.csdn.net/Expert/topic/5742/5742077.xml?temp=.1596949
我想实现使子菜单被打开时自动获取焦点,点击ENTER时它(子菜单)还能打开一个URL连接.
只要您能帮我实现以上两个功能,连同上帖中的100共200分,相送;
代码如下:
<html>
<head>
<style type= "text/css ">
<!--
input {border:1px solid #fff; background:#fff; }
input {star : expression(
onmouseover=function(){this.style.backgroundColor= "#eee "},
onmouseout=function(){this.style.backgroundColor= "#fff "})}
.in40 {width:40px;}
.in80 {width:80px;}
.in120 {width:120px;}
.in200 {width:200px;}
-->
</style>
</head>
<body>
<script defer>
var obj=document.getElementsByTagName( "input ");
var urlpath = " ";
for(var i=0;i <obj.length;i++)
if(obj[i].input)
{
obj[i].focus();
break;
}
document.onkeydown=function()
{
try{
//alert(event.keyCode);
if(event.keyCode==13){
//alert( "现在访问URL ");
window.open();
}
//按esc键退出
if(event.keycode == 27)
window.closed();
if(event.keyCode==40){
event.srcElement.nextSibling.nextSibling.focus();
showNone();
}
else if(event.keyCode==38){
event.srcElement.previousSibling.previousSibling.focus();
showNone();
}
else if(event.keyCode==37){
var xxx = event.srcElement;//event.srcElement就是指向触发事件的元素,他是什么就有什么的属性;srcElement 是事件初始目标的html元素对象引用,因为事件通过元素容器层次冒泡,可以在任一层进行处理,所以由一个属性指向产生初始事件的元素是很有帮助的.有了元素的引用,就可以读/写改元素的属性,并调用他的任何方法.
if(xxx.id == "bb "){
bbb.style.display = "none ";
}else if(xxx.id == "cc "){
ccc.style.display = "none ";
}else if(xxx.id == "dd "){
ddd.style.display = "none ";
}
}
else if(event.keyCode==39){
var xxx = event.srcElement;
if(xxx.id == "bb "){
bbb.style.display = "block ";
}else if(xxx.id == "cc "){
ccc.style.display = "block ";
}else if(xxx.id == "dd "){
ddd.style.display = "block ";
}
}
}catch(e){}
}
function url(obj){
urlpath =obj.value;
//window.location.href=obj;
//alert(obj.value);
}
function showNone(){
bbb.style.display = "none ";
ccc.style.display = "none ";
ddd.style.display = "none ";
}
</script>
<table>
<tr> <td>
<div id= "