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.
感谢乔·约翰逊的出色回答,对于那些对属性的完整列表感兴趣的人,我发现了许多资源:
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 (感谢joe!)
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_html_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
Firefox: 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等-但这不是新的,仅仅是示例).
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屋!