< img title ="< a href ='#'onClick ='alert('Hello World!')>链接< / a>" />可能? [英] JavaScript inside an <img title="<a href='#' onClick='alert('Hello World!')>The Link</a>" /> possible?

查看:127
本文介绍了< img title ="< a href ='#'onClick ='alert('Hello World!')>链接< / a>" />可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < img title =< a href ='#'onClick ='alert('Hello World!')>链接< / a> /> 

所以我有一些具体的问题。我已经知道我可以使用属性TITLE属性..但是我可以使用TITLE属性中的事件吗?



(顺便说一句 - 它看起来像一个垃圾代码,但它已经可以在我的web上运行了项目 - 我只是需要一种方法来在这个护套链接上使用一些javascript。)



I USE Jquery 框架。

解决方案

不,这就是你说的垃圾代码。如果它按照原则工作,那是因为浏览器试图读取作者的思想 - 换句话说,他们有算法来试图理解垃圾代码,猜测可能的意图,并在内部将它改变成实际上换句话说,你的代码只是偶然的工作,可能并不是所有的浏览器。



这是你想要做什么?

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


<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.

解决方案

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>

这篇关于&lt; img title =&quot;&lt; a href ='#'onClick ='alert('Hello World!')&gt;链接&lt; / a&gt;&quot; /&GT;可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆