I created a textbox and wrote onfocus="getFocus()"
Now I wrote function in javascript
function getFocus()
        {
            alert('Hello I Got Focus !!');
        }
The problem is in IE8 it worked perfectly, but in IE9 alert is not showing. Can anyone tell what is wrong with the code ??
I also tried
txtAmt.Attributes.Add("onfocus","getFocus()")
but still it didn't worked
i too tried
txtAmt.Attributes.Add("onfocus","javascript:getFocus();")
Now i am worried.. what to do ??
onFocus should be re-written as onfocus = "getFocus()".
If it still doesn't work, then if IE9 is newly installed, you might want to check if Javascript is enabled in your installation of IE9. :)
try javascript tag :
txtAmt.Attributes.Add("onfocus","javascript:getFocus();")
Your code seems fine, have you tried checking the security settings of IE?
if you go
 Internet Options > Security > Custom level > 
 Make sure Active Scripting is not set to Disabled
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With