Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working in Firefox or IE #6

Open
brightrain opened this issue Jan 13, 2016 · 2 comments
Open

Not working in Firefox or IE #6

brightrain opened this issue Jan 13, 2016 · 2 comments

Comments

@brightrain
Copy link

I've got things working for several d3 generated svgs but it only works in Chrome. After some debugging I'm finding that the callbacks are not being fired in IE (11) or Firefox (43.0.4) on Windows. For example, I am calling download which calls toImg and passes in a callback function but that callback function never fires. This is true for all of the callbacks. I have attempted to set breakpoints in dev tools and also added some console.logs in the callbacks that confirmed this.

I will continue to do debug and if I come up with a fix I'll do what I can to implement it. Meantime, any thoughts here?

@brightrain
Copy link
Author

I believe I have worked this out and will document in case anyone else has this issue.

IE simply doesn't support the download attribute which is what is used here.
http://caniuse.com/#feat=download

Firefox required that I insert the anchor link into the dom before it would fire the download. Perhaps there's a more elegant solution but adding this to the download function before triggering the click event worked for me (not setting text ensures it isn't visible):

a.href = img.getAttribute('src');
// added this line
document.getElementById("idOfElement").appendChild(a);
a.click();

@krunkosaurus
Copy link
Owner

Thanks @brightrain. I've added support for this Firefox workaround in the latest code. I don't have an IE machine on hand to test, but will take a look when I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants