JavaScript inside an <img title="<a href='#' onClick='alert('Hello World!')>The Link</a>" /> possible?
No, this is, as you say "rubbish code". If it works as should, it is because browsers try to "read the writer's mind" - in other words, they have algorithms to try to make sense of "rubbish code", guess at the probable intent and internally change it into something that actually makes sense.
In other words, your code only works by accident, and probably not in all browsers.
Is this what you're trying to do?
<a href="#" onClick="alert('Hello World!')"><img title="The Link" /></a>
When you click on the image you'll get the alert:
<img src="logo1.jpg" onClick='alert("Hello World!")'/>
if this is what you want.
Im my browser, this doesn't work at all. The tooltip field doesn't show a link, but <a href='#' onClick='alert('Hello World!')>The Link</a>
.
I'm using FF 3.6.12.
You'll have to do this by hand with JS and CSS. Begin here