javascript problem in IE v5.

G

Guest

Hi,

I got this problem, I developed my asp.net c# apps in my own pc that has
IE6, and I recently moved it onto the server that is using IE v5. I found out
that my javascript is not compatible with IE5. Can someone please help me to
spot where and why there is now an error in my javascript ? I have listed it
below:

<script language="javascript">
function CheckKey() {
if (event.keyCode == 13) { //enter
document.getElementById("btnRQn").focus();
}
if (event.keyCode == 9) { //tab
document.getElementById("btnRQn").focus();
}
if (event.keyCode == 27) { //esc
document.getElementById("btnRQn").focus();
}
if (event.keyCode >= 166 && event.keyCode <= 172) {
document.getElementById("lblDisplayName").focus();
}
}
</script>

Many thanks.
Andrew.
 
P

Patrice

Enable JavaScript error reporting in your browser and it should easily show
up in your debugger plus you'll vbe able to make tries in the command
window...
 
I

intrader

Hi,

I got this problem, I developed my asp.net c# apps in my own pc that has
IE6, and I recently moved it onto the server that is using IE v5. I found out
that my javascript is not compatible with IE5. Can someone please help me to
spot where and why there is now an error in my javascript ? I have listed it
below:

<script language="javascript">
function CheckKey() {
if (event.keyCode == 13) { //enter
document.getElementById("btnRQn").focus();
}
if (event.keyCode == 9) { //tab
document.getElementById("btnRQn").focus();
}
if (event.keyCode == 27) { //esc
document.getElementById("btnRQn").focus();
}
if (event.keyCode >= 166 && event.keyCode <= 172) {
document.getElementById("lblDisplayName").focus();
}
}
</script>

Many thanks.
Andrew.
getElementById is your problem. Simply use document.all instead.
This also works in IE6
 
A

Alvin Bruney - ASP.NET MVP

You didn't say what the problem was? What issue are you experiencing/script
error???

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
B

Bruce Barker

actually IE 5.5 supports getElementById, but is good coding pratice to
check:

function myGetlElementById(id)
{
if (document.getElementById)
return document.getElementById(id);
else if (document.all)
return document.all[id];
return null;
}

-- bruce (sqlwork.com)
 
G

Guest

Is the syntax for this correct ?

document.all.item("btnLogin").focus();

many thanks.
Andrew
 
G

Guest

I have the error in my html body code where i call the event to check for
keyCodes ie. onkeydown="CheckKey(event);"

Thanks
Andrew

Alvin Bruney - ASP.NET MVP said:
You didn't say what the problem was? What issue are you experiencing/script
error???

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Andrew said:
Hi,

I got this problem, I developed my asp.net c# apps in my own pc that has
IE6, and I recently moved it onto the server that is using IE v5. I found out
that my javascript is not compatible with IE5. Can someone please help me to
spot where and why there is now an error in my javascript ? I have listed it
below:

<script language="javascript">
function CheckKey() {
if (event.keyCode == 13) { //enter
document.getElementById("btnRQn").focus();
}
if (event.keyCode == 9) { //tab
document.getElementById("btnRQn").focus();
}
if (event.keyCode == 27) { //esc
document.getElementById("btnRQn").focus();
}
if (event.keyCode >= 166 && event.keyCode <= 172) {
document.getElementById("lblDisplayName").focus();
}
}
</script>

Many thanks.
Andrew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top