HTML: onpaste=“doSomething();” as invalid attribute

依然范特西╮ 提交于 2019-12-01 19:23:11

http://reference.sitepoint.com/html/extended-event-attributes/onpaste

"Non-standard event defined by Microsoft for use in Internet Explorer. May work in some other browsers but cannot be reliably used. Compatibility for this non-standard attribute not tested."

The Amaya editor performs a syntax check using a document type definition, and its built-in repertoire includes only doctypes that do not allow the onpaste attribute. That’s why you get the error message.

There’s probably no way around this message in Amaya. You can use Tools → Change doctype → Remove the doctype or, better, manually change, in Show Source mode, the doctype declaration to <!doctype html>, the HTML5 doctype. But Amaya still keeps checking against the specification it regards as the correct one.

Amaya is an editor (and a testbed browser), not a checker. Use a validator to check your syntax. Then you can use <!doctype html> to specify HTML5. Beware that HTML5 has some oddities, and contrary to popular misconceptions, it is not a pure extension of HTML 4.01. And apparently because Amaya decides to remove the attribute, you would need to use a different editor.

Whether onpaste is useful and safe to use is a different question.

Update (July 2018): Over the years that have passed, onpaste has not become part of official HTML, so a validator issues an error message about it. Yet, support appears to appear e.g. in Chrome. If you need to avoid validation errors (or your editor removes an onpaste attribute), use JavaScript to assign a value to the onpaste property of the element node instead of using an attribute in HTML markup.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!