Issue
How to create listener on document.createElement func?
For example, after
var canvas = document.createElement("canvas");
it was done automatically
console.log("createElement worked")
P.S. how to do the same but with different functions, for example toDataURL
var str = canvas.toDataURL("image/png");
it was done automatically
console.log("toDataURL worked")
Solution
You can override the original function and add your desired code extension at the beginning.
document.createElement = function (create) {
return function() {
console.log ('element created');
return create.apply (this, arguments);
};
}(document.createElement)
Example adapted from Hooking document.createElement using function prototype
Answered By - flappix Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.