Tried uw.document.getElementById to see if that helps it not to be undefined.