Created
December 30, 2016 22:06
-
-
Save hoffination/022674922cb8428d95b7449c93655e8c to your computer and use it in GitHub Desktop.
Great way to display downloadable data in a new tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = {a: 123, b: "4 5 6"}; | |
var container = document.getElementById('container'); // some div on the page | |
container.addEventListener('click', function() { | |
var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(obj)); | |
window.open("data://" + data, "_blank"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment