Phl wrote:
here is the custom element I am trying to access:
<prog:ComboBox id="insert_prjcode" name="insert_prjcode"
ParentFormID="Form1"
ResourcesDirectory="/webctrl_client/progstudios/1_2/" value="1"
size="5" onchange="__doPostBack('insert_prjcode','')">
here is the javascript which i used to access but fails , when i try
and use the onfocus method:
<SCRIPT language='javascript'>var cobj =
document.getElementById('insert_prjcode');
if(!cobj){alert('failed');}else{alert('passed');co bj.focus();}
Does this make the problem clearer?
thx
You aren't using the "onfocus" method, you're using the "focus" method.
However, you aren't testing to see whether the object supports the
focus() method before you attempt to use it.
Start with this:
<script type="text/javascript">
var cobj = document.getElementById('insert_prjcode');
if (cobj) {
alert(cobj.focus);
}
</script>
If you get no alert, the object isn't being retrieved correctly.
If you get the alert(), but see anything other then:
function focus() {
[native code]
}
then the focus method isn't supported by your object. Even if you get
the text described above, the "native code" may not actually set the
focus, or it may attempt to set the focus, but other issues within the
user agent prevent that from happening. Once you have determined that
the object supports the focus() method, then the proper test for usage
would be:
if (cobj && cobj.focus) {
cobj.focus();
}
--
| Grant Wagner <gw*****@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html