Grab the elementbyid, if it returns false then the field does not exist.
var f = document.forms[0];
var LinkaExists = document.getElementById('Linka');
var LinkbExists = document.getElementById('Linkb');
if ( LinkbExists )
{
f.Linkb.focus();
}
else if ( LinkaExists )
{
f.Linka.focus();
}
You can then also check the value depending on the type of the field, using f.type
eg: LinkaExists.type.lowercase=='text' or 'textarea' or 'checkbox' or 'select-one' etc.