Fix typo useragent to userAgent
Catch a exception if clientWidth/clientHeight is undefined