M
MNF
Hi everyone,
I am using document.getElementById function in JavaScript to find a
control within an html body, but instead I get back META item, because
incidently the name of one meta tags is the same as the name of my
control. It seems that it is by design, because getElementById returns
the FIRST object with the same ID.
What is the best general workaround to search control only within
body?
I prefer to allow control IDs be the same as meta tag names.
Thanks,
Michael Freidgeim
Please find the sample page to illustrate the issue.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta content="Functional Solutions"
name="keywords">
</HEAD>
<body >
<form name="Form1" method="post" action="" id="Form1">
<input type="text" id="Keywords" >
<script type='text/javascript'>
<!--
SetFocus('Keywords');
function SetFocus(strID, bFindCtrl)
{
ctl = document.getElementById(strID);
// If not found, exit
if(ctl == null || typeof(ctl) == "undefined")
return false;
ctl.focus();//causes error
}
//-->
</script>
</form>
</body>
</HTML>
I am using document.getElementById function in JavaScript to find a
control within an html body, but instead I get back META item, because
incidently the name of one meta tags is the same as the name of my
control. It seems that it is by design, because getElementById returns
the FIRST object with the same ID.
What is the best general workaround to search control only within
body?
I prefer to allow control IDs be the same as meta tag names.
Thanks,
Michael Freidgeim
Please find the sample page to illustrate the issue.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta content="Functional Solutions"
name="keywords">
</HEAD>
<body >
<form name="Form1" method="post" action="" id="Form1">
<input type="text" id="Keywords" >
<script type='text/javascript'>
<!--
SetFocus('Keywords');
function SetFocus(strID, bFindCtrl)
{
ctl = document.getElementById(strID);
// If not found, exit
if(ctl == null || typeof(ctl) == "undefined")
return false;
ctl.focus();//causes error
}
//-->
</script>
</form>
</body>
</HTML>