javascript - <img src="x" onerror="alert(\"hello\")" />) escaping quote is illegal? -
i trying play around escape character.
<img src="x" onerror=alert('hello'); /> <img src="x" onerror="alert(\"hello\")" />
the 2nd 1 produces illegal character
in dev console. why? why can't use escape character?
because \
not escape character in html.
<img src="x" onerror="alert("hello")" />
or, per @mplungjan's comment:
<img src="x" onerror="alert('hello')" />
or, better still:
<img src="x" id="derp" /> <script type="text/javascript"> document.getelementbyid('derp').addeventlistener("error",function() { alert('hello'); },false); </script>
Comments
Post a Comment