[thelist] JavaScript focus & getElementByID

Martyn Haigh martyn.haigh at virgincosmetics.com
Wed Jan 15 09:14:01 CST 2003


Could someone explain to me why this doesn't work - Javascript is the bane
of my life!!

I have a simple API :

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


I have this input element
<input type="checkbox" id="KnowMore" name="KnowMore" value="True" />


And I have this JS Code :

	x = new getObj('KnowMore');
	x.focus();

but it just comes up with an error on the focus line.

Can anyone see where I'm going wrong.

Thank you

Martyn


DISCLAIMER: The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this email by
anyone else is unauthorised. If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be taken
in reliance on it, is prohibited and may be unlawful.





More information about the thelist mailing list