javascript problem in IE v5.

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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...
 
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
 
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
 
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)
 
Is the syntax for this correct ?

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

many thanks.
Andrew
 
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.
 
Back
Top