鼠标流触发onb​​eforeunload不起作用

时间:2019-12-13 10:26:26

标签: javascript

在onbeforunload上调用mouseflow反馈触发器

<script type="text/javascript">
window._mfq = window._mfq || [];
  (function() {
    var mf = document.createElement("script");
    mf.type = "text/javascript"; mf.async = true;
    mf.src = "//cdn.mouseflow.com/projects/bd430861-d793-4319-964b-a8daeb7f2097.js";
    document.getElementsByTagName("head")[0].appendChild(mf);
  })();

/* the above script is provided by mouseflow itself */

  function startSurvey() {
    window._mfq = window._mfq || []; 
    window._mfq.push(['activateFeedback', 'mouseflow_code']);
  }
  window.onbeforeunload = function (e) {
    e = e || window.event;
    startSurvey();
    // For IE and Firefox prior to version 4
    if (e) {
      e.returnValue = 'Sure?';
    }
    // For Safari
    return 'Sure?';
  };
</script>

onbeforeunload函数运行良好,但没有触发mouseflow触发器。

0 个答案:

没有答案