Stand Coder Stand Coder - 7 months ago 36
Javascript Question

How to send http request on img tag's onerror attribute?

I've tried as follows, but it doesn't work

<img src=a onerror="document.write('<img src=\"\">')">


\ is not an escape character in HTML.

To put a " character inside an attribute value delimited with " characters, you must represent it as an entity. e.g. &quot;.

Keep in mind that cross-origin restrictions prevent load and error events firing on images srced from a different origin.