I'm looking for a simple list of all the html attributes that can contain javascript that will automatically run when an action is performed. I know this will differ between browsers and versions but I'd rather be safer than sorry. I currently know of the following javascript attributes: onload
, onclick
, onchange
, onmouseover
, onmouseout
, onmousedown
, and onmouseup
Backstory: I'm getting a full html document from an untrusted source and I want to strip all javascript that could run from the original html document so I'm removing all script tags as well as any attributes that could hold javascript before its displayed in an iframe. For this implantation there is no server side processing and no way of sandboxing the code since I need to run javascript that is being added locally after all of the original javascript is removed.
Property Attributes Other attributes are: enumerable, configurable, and writable. These attributes define how the property can be accessed (is it readable?, is it writable?) In JavaScript, all attributes can be read, but only the value attribute can be changed (and only if the property is writable).
HTML attributes are generally classified as required attributes, optional attributes, standard attributes, and event attributes: Usually the required and optional attributes modify specific HTML elements. While the standard attributes can be applied to most HTML elements.
There are two places where Javascript can be used in HTML attributes:
Any onEVENT
attribute. I suggest just treating any attribute that begins with on
as an event binding, and strip them all out.
Any attribute that can contain a URI will be executed as Javascript if the URI uses the javascript:
scheme, such as href
and src
. A complete list is in
COMPLETE list of HTML tag attributes which have a URL value?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With