Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript inside an <img title="<a href='#' onClick='alert('Hello World!')>The Link</a>" /> possible?

<img title="<a href='#' onClick='alert('Hello World!')>The Link</a>" /> 

So I've got some specific question.. I already know that I can work with attributes inside a TITLE attribute.. But can I work with events inside a TITLE attribute?

(btw - It seems like a rubbish code, but this already works as is should on my web project - I just need a way to use some Javascript on this sheathed link.)

I USE Jquery framework.

like image 703
Tomkay Avatar asked Nov 26 '10 08:11

Tomkay


People also ask

What is a link title attribute?

Link title attribute. The Link title is an optionally defined attribute to give additional, advisory information about a linked web site. It helps clarify or further describe the purpose of a link that a recipient should know before clicking it.

What is the use of title attribute in anchor tag?

The title attribute is used to provide additional information to help clarify or further describe the purpose of a link.


1 Answers

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>
like image 121
Piskvor left the building Avatar answered Oct 05 '22 01:10

Piskvor left the building