Last active
March 1, 2017 17:44
-
-
Save MiguelSavignano/b9e3264ecaea213620edc99d3b08588c to your computer and use it in GitHub Desktop.
This delete the onclick string in the html dombut it's works same, auto create event listener with the code Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.ClearDOM = { | |
clearOnClick: function(element){ | |
var code_block = $(element).attr('onclick') | |
$(element).on('click', function(event){ | |
eval( code_block ) | |
}) | |
$(element).attr('onclick', '') | |
}, | |
run: function(selector){ | |
$('*[onclick]').toArray().forEach( (element) => ClearDOM.clearOnClick(element) ) | |
} | |
} | |
ClearDOM.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
<a onclick="console.log('its bad write here?')" >Example</a>
ClearDom.run()
Result
Example