Javascript, track iframes redirecting top window

前端 未结 4 1468
谎友^
谎友^ 2021-02-12 23:38

Since there is no way to prevent an iframe from redirecting the top frame besides sandboxing which prevents other features required for viewability tracking I would like to trac

4条回答
  •  情歌与酒
    2021-02-13 00:19

    You can show a dialog box before redirecting to another domain/application and then the user can decide - to stay or leave the current application. You can also track the current target (i.e. iframe in your case).

    window.onbeforeunload = function (e) {
      console.log(e.currentTarget.location.href);
      return 'Stop redirection. Show dialog box.';
    };
    

提交回复
热议问题