in external script
Silly question, but where in the code are you including said script? If you put the script inside your HEAD before the LINK in the code, said LINK won't exist on the DOM yet.
Might not be your problem -- hard to say without seeing the full code -- but that's the number one place people have issues moving from internal scripts to external, trying to "get" things that don't exist yet on the DOM.
This is part (alongside being faster) of why one of the better practices and common optimizations is to write all your scripts in such a manner that you place ALL of them right before you close BODY. At that point you pretty much know the DOM is fully built, and it means a lot of stuff people waste time throwing window.onload at can just be run flat without it.
NOT that the code you presented makes much sense, as where do you actually call your "try'. Try is also a bad name for a function since TRY is a reserved word / language construct. Likewise where is "element" even defined?
... and yeah, Marco Alka has it right, you should likely be using addEventListener just in case other scripts try to hook the same element. Only time you really should be considering onclick is if you just created it with document.createElement