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

Create a link to download the svg via javascript #7

Open
goinnn opened this issue Jun 5, 2013 · 1 comment
Open

Create a link to download the svg via javascript #7

goinnn opened this issue Jun 5, 2013 · 1 comment

Comments

@goinnn
Copy link
Owner

goinnn commented Jun 5, 2013

Something like this:

document.location = 'data:image/svg+xml,' + encodeURIComponent("hello world!");
@goinnn
Copy link
Owner Author

goinnn commented Jun 5, 2013

Something like this:

<script type="text/javascript">
    (function($){
        $(document).ready(function () {
            $("#download").click(function(){
                $(this).attr("href", 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent("hello world!"));
            });
        });
      })(jQuery);
</script>

And:

<a id="download" download="mygraph.svg" href="#download">Download</a>

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

No branches or pull requests

1 participant