views:

85

answers:

1

hi my dear friends :

i do not know what is going on my firefox!

my aspx and javascript codes are like this :

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function a() {
            alert('a');
            //alert(event.which);
            //alert(event.keyCode);
            //alert(event.charCode);
        }
        function b() {
            alert('b');
            //alert(event.which);
            //alert(event.keyCode);
            //alert(event.charCode);
        }
        function c() {
            alert('c');
            //alert(event.which);
            //alert(event.keyCode);
            //alert(event.charCode);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" onkeyup="a()"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" onkeydown="b()"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server" onkeypress="c()"></asp:TextBox>
    </div>
    </form>
</body>
</html>

when i type something in textbox 1,2,3 so i see just first alert (mean a,b,c).

what is the problem ?

thanks in future advance...

+3  A: 

It works in IE because there, event is a global variable.

In Firefox, the event object is passed to the event handler, so you have to make the function accept a parameter:

function a(event) {
    event = event || window.event // IE does not pass event to the function
    alert('a');
    alert(event.which);
    alert(event.keyCode);
    alert(event.charCode);
}

And in your HTML, you have to write:

<asp:TextBox ID="TextBox1" runat="server" onkeyup="a(event)"></asp:TextBox>

Btw. you could have easily spot this by using Firebug. It throws an error in the console.

Felix Kling
thanks for your answer ... solved
LostLord