javascript convert enterkey to tabkey for all browsers(IE,Firefox,Opera,Google chrome)
I want solution to this problem,In Asp.Net convert enterkey to tabkey for all browsers(IE,Firefox,Opera,Google chrome).give me example..
<html>
<script>
function enterToTab(event){
var key = event.keyCode
if(key==13)
{
event.keyCode =9;
return true;
}
return false;
}
</script>
<body>
<form name='frm' >
<table>
<tr>
<td><input type = text name="A" tabindex=1 id="elem1"
onkeydown="enterToTab(event);"><td>
<td><select type = select name="B" tabindex=3 id="elem3"
onkeydown="enterToTab(event);">
<option value = "R" selected>Red
<option value = "B">Blue
<option value = "G">Green
</select><td>
<td><input type = text name="C" tabindex=2 id="elem2"
onkeydown="enterToTab(event);"><td>
<tr>
<td><开发者_Python百科input type = text name="D" tabindex=4 id="elem4"
onkeydown="enterToTab(event);"><td>
<td><textarea name="E" tabindex=6 id="elem6"></textarea>
<td>
<td><input type = text name="F" tabindex=5 id="elem5"
onkeydown="enterToTab(event);">
<input type = text name="F" tabindex=7 id="elem7"
onkeydown="enterToTab(event);"><td>
<tr>
<table>
</form>
</body>
</html>
thanks in advance..
event.keyCode is writeable only in MSIE, so you can't simply "convert" this function to make it work cross-browser.
You'll need a more complex script that parses the document to build a stack of elements affected by tab-inputs(those having a tabIndex-property >0) and give them the focus accordingly to the current element.
What else: for me the TAB has keyCode 9
精彩评论