Answer the question
In order to leave comments, you need to log in
Does not catch the submit event from the connected js, where to dig?
Task: Catch the form firing on the page.
There is the following code:
$(document).ready(function () {
$(document).on('submit','form',function(e){
alert('wtf?');
})
})
h.redirect = function (a, b) {
var c = k.createElement("form");
c.action = b;
c.method = "post";
c.target = "_top";
c.style.display = "none";
var d = k.createElement("input");
d.type = "hidden";
d.name = "token";
d.value = a;
c.appendChild(d);
k.body.appendChild(c);
c.submit()
}
Answer the question
In order to leave comments, you need to log in
In general, it's not very cool that a third-party script allows itself such liberties as a direct call to submit , or maybe it's some specific one. This approach leaves no choice but to decorate:
(() => {
var old_submit = HTMLFormElement.prototype.submit;
HTMLFormElement.prototype.submit = function() {
var form = this,
args = Array.prototype.slice.call(arguments),
submit_event = new Event('submit', {
bubbles: true,
cancelable: true
});
submit_event.original_submit = function() {
old_submit.apply(form, args);
};
form.dispatchEvent(submit_event);
}
})();
$(() => {
var my_form = $( 'form' )[0];
$( document )
.on('submit', 'form', function(e) {
alert('wtf?');
e.originalEvent.original_submit();
})
.on('click', 'button', function() {
my_form.submit();
});
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question