CallConnection
asked on
send arrow keystroke in c# or javascript ( or vb .net ) to IE browser window
Is there any way I can send a keystroke to a browser from Javascript or .net - C#? I am looking for forward arrow key in paricular. It only needs to work in IE, and actually only on the local intranet.
...I expect there may not be a Javascript solution, but maybe I can track an hidden element on the page - and when it's changed I send the key?
I might also accept a solution in VB, but C# would be much better.
...I expect there may not be a Javascript solution, but maybe I can track an hidden element on the page - and when it's changed I send the key?
I might also accept a solution in VB, but C# would be much better.
you can access the keyCode
function getKey(e) {
var e = e || window.event;
alert(e.keyCode);
}
<html>
<head>
<title></title>
<script type="text/javascript">
function getKey(e) {
var e = e || window.event;
alert(e.keyCode);
}
</script>
</head>
<body onkeydown="getKey(event);" >
</body>
</html>
function getKey(e) {
var e = e || window.event;
alert(e.keyCode);
}
<html>
<head>
<title></title>
<script type="text/javascript">
function getKey(e) {
var e = e || window.event;
alert(e.keyCode);
}
</script>
</head>
<body onkeydown="getKey(event);"
</body>
</html>
ASKER
Guys, that's ok, but I am looking to SEND a keystroke from the web appication (not GET what the user pressed)... [This to resolve a strange IE glitch I have come across.]
That's why I wondered if C# can actually do it?.. But thinking about it C# would probably only cater for server-side events so that sound unlikely... Still I thought I'd check with you to make sure.
That's why I wondered if C# can actually do it?.. But thinking about it C# would probably only cater for server-side events so that sound unlikely... Still I thought I'd check with you to make sure.
what would you like to achieve with sending this arow key? To scroll the window or something?
Andrew
Andrew
ASKER
Basically I was trying to save some time to help users not have to re-enter the same information in the second box (similar to simplified eg below).
But I have a strange IE bug - the cursor is set to a correct control on the page, but it's not visible...
But I can tell that it is the right control because I can pick it up with onFocus event and it also appears in the right box when you press any key.
Please have a look at this:
<html>
<body>
<script>
function d()
{
document.getElementById('i d2').value = document.getElementById('i d1').value ;
}
</script>
<input id="id1" type="text" value="1234" onblur="d()"></input>
<input id="id2" type="text" value="1234"></input>
</body>
</html>
Any thoughts?
But I have a strange IE bug - the cursor is set to a correct control on the page, but it's not visible...
But I can tell that it is the right control because I can pick it up with onFocus event and it also appears in the right box when you press any key.
Please have a look at this:
<html>
<body>
<script>
function d()
{
document.getElementById('i
}
</script>
<input id="id1" type="text" value="1234" onblur="d()"></input>
<input id="id2" type="text" value="1234"></input>
</body>
</html>
Any thoughts?
<html>
function d()
{
document.getElementById('i d2').value = document.getElementById('i d1').value ;
}
</script>
</head>
<body >
<input id="id1" type="text" value="1234" onblur="d()"></input>
<input id="id2" type="text" value="1234"></input>
</body>
</html>
For me it works fine!! Try to put your script well outside body tag like what i did
Regards
Renju
function d()
{
document.getElementById('i
}
</script>
</head>
<body >
<input id="id1" type="text" value="1234" onblur="d()"></input>
<input id="id2" type="text" value="1234"></input>
</body>
</html>
For me it works fine!! Try to put your script well outside body tag like what i did
Regards
Renju
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I see what you mean - the above works when users CLICK the second box, but as far as I can see it does not work (in IE 6 / IE 7) when users change the text in the first box and press tab key to get to the second box. The cursor is invisible until you press another key.... Hence the question above --- or can you see another way to fix this?
(By the way I am using onblur events in both textboxes for other purposes...)
(By the way I am using onblur events in both textboxes for other purposes...)
ASKER
I think have fixed this by using onfocus="this.select()"... which means the whole field is selected but at least user knows where he is... Thanks guys!!
<body onkeypress="function_Call(
function function_Call()
{
// set a flag into hidden field
}
you can get onclick event also for mouse click
Regards
Renju