sonyerricsonk75
08-28-2007, 06:18 AM
hi all,
i have created a very application by this code :
<html>
<head>
<script type="text/javascript">
var x=undefined
window.onload=function()
{
x=document.getElementsByTagName('a')
for (var i=0;i<x.length;i++)
x[i].onkeydown=go
}
function go(y)
{
var key=y.keyCode
var obj=y.target
if (key!=38 && key!=40) return
var dir=key==38?-1:1
var z=-1
for (var i=0;i<x.length;i++) if (x[i]==obj) z=i
if (z==-1) return
x[(z+x.length+dir)%x.length].focus()
}
</script>
</head>
<body>
<a href="test41_1.html">test41_1</a>
<ul>
<li><a href="test41_1.1.html">test 41_1.1</a></li>
<li><a href="test41_1.2.html">test 41_1.2</a></li>
</ul>
<a href="test41_2.html">test 41_2</a>
<br><a href="test41_3.html">test 41_3</a>
<br><a href="test41_4.html">test 41_4</a>
<br><a href="test41_5.html">test 41_5</a>
</body>
</html>
the output of it is as :
test41_1
* test41_1.1
* test41_1.2
test41_2
test41_3
test41_4
test41_5
problem is by the UP and DOWN arrow ,I can navigate in the links.
I want to use LEFT and RIGHT keys as well for navigating in childs and parents links.
by clicking on LEFT arrow key,the focus should come at parent link,and vice-versa.
do anyone knows how to make it?
thnx
S
i have created a very application by this code :
<html>
<head>
<script type="text/javascript">
var x=undefined
window.onload=function()
{
x=document.getElementsByTagName('a')
for (var i=0;i<x.length;i++)
x[i].onkeydown=go
}
function go(y)
{
var key=y.keyCode
var obj=y.target
if (key!=38 && key!=40) return
var dir=key==38?-1:1
var z=-1
for (var i=0;i<x.length;i++) if (x[i]==obj) z=i
if (z==-1) return
x[(z+x.length+dir)%x.length].focus()
}
</script>
</head>
<body>
<a href="test41_1.html">test41_1</a>
<ul>
<li><a href="test41_1.1.html">test 41_1.1</a></li>
<li><a href="test41_1.2.html">test 41_1.2</a></li>
</ul>
<a href="test41_2.html">test 41_2</a>
<br><a href="test41_3.html">test 41_3</a>
<br><a href="test41_4.html">test 41_4</a>
<br><a href="test41_5.html">test 41_5</a>
</body>
</html>
the output of it is as :
test41_1
* test41_1.1
* test41_1.2
test41_2
test41_3
test41_4
test41_5
problem is by the UP and DOWN arrow ,I can navigate in the links.
I want to use LEFT and RIGHT keys as well for navigating in childs and parents links.
by clicking on LEFT arrow key,the focus should come at parent link,and vice-versa.
do anyone knows how to make it?
thnx
S