K
K
kn1ght_t2015-05-22 15:10:27
JavaScript
kn1ght_t, 2015-05-22 15:10:27

Why does the metric target fire on click?

What's the point of setting the onsubmit target in this way if it will still work on a normal submit click (even if the form is not submitted)?
ps I tried to insert console.log into onsubmit for the first option to insert a metric, which worked every time with a normal click

<html>
    ...
    <form action="" method="get" onsubmit="yaCounterXXXXXX.reachGoal('ORDER'); return true;">
        ...
    </form>
    ...
</html>

As far as I understand, with this option, the same thing will happen
<html>
    ...
    <form action="">
        ...
        <input type="button" onclick="yaCounterXXXXXX.reachGoal('ORDER'); return true;" value="Заказать" />
    </form>
    ...
</html>

question: how can I prevent the onsubmit event from firing on a normal click? as far as I understand, adding the required attribute to one of the inputs will save

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Vsk, 2015-05-22
@viktorvsk

on a normal submit click (even if the form is not submitted)

What do you have in mind?
Here the event does not fire if the form is not filled: jsfiddle.net/xcnm3L1p

E
Elios, 2015-05-23
@strelov1

In such cases, I usually make a 1-pixel image that appears on the page at the right time, and I already hang the onload event on the image.
To watch all these moments, there is a plugin https://addons.mozilla.org/ru/firefox/addon/metrik. ..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question