For level 2, onerror="javascript:alert(0)" a whole lot simpler than your pasted answer.
img tags support the onload attribute and is a typical element people use in posts
<img src="404me" onerror="alert('test')" />Maybe it doesn't work because the page is already loaded so the onload is never run.