OSX Safari Frame Load Interrupted

前端 未结 2 1167
遥遥无期
遥遥无期 2021-01-17 09:16

I have a basic HTML website (with some javascript) using a simple anchor tag to download a file like so:



        
相关标签:
2条回答
  • 2021-01-17 09:54

    The only solution I can think of - is waiting till GA request will finish, and only after that set location.href to desired file download link. But this is not really good from user's perspective. (This can be achieved with hit callback https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#hitCallback).

    Probably HTML5 download attribute for href will solve the problem. I have no OSX with safari to test, so this is only my thoughts.

    0 讨论(0)
  • 2021-01-17 10:14

    If you always want to get the ga event then the hitCallback is likely the only way to go until whatever is wrong with Safari is fixed. I use a similar pattern to send a GA event from a page in an app which is just a redirect after a whole load of database stuff has been executed in rails. There is no noticeable lag from adding the javascript redirect into the callback. However I am not sure how to initiate the download from javascript off the top of my head.

    ga('send','event','Download','MexmlSample','MexmlSample-1.0', {
       hitCallback: function(){
       initiateDownload();
       })
    

    I am not aware of any need to use the setTimeout() for pattern in this instance.

    0 讨论(0)
提交回复
热议问题