asafdav / ng-csv

Simple directive that turns arrays and objects into downloadable CSV files
MIT License
573 stars 215 forks source link

Safari download breaking because of popup blocker #84

Open chesleybrown opened 9 years ago

chesleybrown commented 9 years ago

From the discussion on Pull Request #83

After some additional testing with this workaround I've discovered it has a caveat. If the user has "Block pop-up windows" enabled in Safari (which I believe is the default) then the directive link silently fails. If I disable "Block pop-up windows" it works as expected.

So if you do add this setting, it might be better to at least make it an optional setting as it seems to completely break downloading in Safari by default.

This is related to how you generate an anchor tag with a target and then click it using JS. I haven't tested it, but a possible workaround would be to not dynamically generate the anchor tag like that and instead apply those attr values to the ng-csv element itself. Then as long as ng-csv is used on an anchor tag this target=_blank might work correctly?