HTML5 中的所有 inline-js 属性是什么? [英] What are all of the inline-js attributes new in HTML5?
问题描述
我需要一个可以接受内联 JS 的所有属性的列表.(是的,由于 javascript: 能力,我会将 href 标记视为这样的属性.
I need a list of all of the attributes that can accept inline JS. (yes, I would count the href tag as such an attribute due to the javascript: ability).
我已经为此搜索了很多,但到目前为止,只有与为什么不应该使用内联 JS"相关的结果.我什至尝试过查找 HTML5 属性周期列表.我设法找到了 HTML4 列表(http://www.w3.org/TR/html4/index/attributes.html),所以我有所有的 HTML4 内联代码属性...
I have been googling around for this quite a bit, but thus far, only results relating to "why you shouldn't use inline JS". I've even tried finding a list of HTML5 attributes period. I managed to find a list for HTML4 (http://www.w3.org/TR/html4/index/attributes.html), so I have all of the HTML4 inline-code attributes...
但是,我不知道 HTML5 是否引入了任何使用内联 js 的新属性.有什么想法吗?
However, I have no idea if HTML5 introduced any NEW attributes that use inline js. Any ideas?
对不起——我没说清楚:
I am sorry -- I failed to make this clear:
我不是想使用内联 JS——我是想阻止其他人使用它.
I am not trying to use inline JS -- I am trying to stop others from using it.
我正在为一个网站项目工作,该项目已经好几年没有任何过滤的 HTML 了.我们经历了一次又一次的攻击.我终于说服了网站的创建者让我创建一个函数来过滤掉 HTML 中的所有 JS.我完成这个才发现我已经完全忘记了内联 JS.我想要一个所有内联 JS 属性的完整列表,以便我也可以停止它们.
I am working on a project for a website which has gone years without any sort of filtered HTML whatsoever. We have gone through attack after attack. I have finally convinced the website's creator to let me create a function that will filter out all JS from the HTML. I finished this only to find out that I had completely forgotten about inline JS. I would like a comprehensive list of all inline JS attributes so that I may stop them as well.
感谢 Joe Johnson 的出色回答,我为那些也对完整属性列表感兴趣的人找到了大量资源:
Thanks to Joe Johnson's great answer, I've found numerous resources for those who are also interested in a complete list of attributes:
HTML4 事件属性:
http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-module(谢谢乔!)
http://www.w3.org/TR/html4/index/attributes.html
HTML4 event attributes:
http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-module (Thanks joe!)
http://www.w3.org/TR/html4/index/attributes.html
HTML5 新事件属性:
http://www.w3schools.com/html5/html5_ref_eventattributes.asp
HTML5 new event attributes:
http://www.w3schools.com/html5/html5_ref_eventattributes.asp
浏览器特定属性:
iOS:http://developer.apple.com/library/ios/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
IE:reference.sitepoint.com/html/extended-event-attributes
火狐:developer.mozilla.org/en-US/docs/Gecko-Specific_DOM_Events一>
Browser-Specific attributes:
iOS:http://developer.apple.com/library/ios/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
IE:reference.sitepoint.com/html/extended-event-attributes
Firefox:developer.mozilla.org/en-US/docs/Gecko-Specific_DOM_Events
推荐答案
据我所知,没有接受 javascript: 协议(例如 href)或事件处理程序之外的内联 JS 的新属性.然而,HTML5 引入了许多新的事件处理程序(on[click,mouseenter,mouseleave,etc]——这些不是新的,只是示例).
As far as I'm aware, there are no new attributes which accept javascript: protocol (such as href) or inline JS outside of event handlers. However, HTML5 has introduced many new event handlers (on[click,mouseenter,mouseleave,etc] -- these are not new however, just examples).
我讨厌在这里打败一匹死马……但是,你发现的一切都一针见血——尽量避免内联 JS.
I hate to beat a dead horse here... but, everything you've found is hitting the nail on the head -- try to avoid inline JS.
这篇关于HTML5 中的所有 inline-js 属性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!