I have a <div>
on my page that is constantly updated every 3 seconds. I'm using setInterval
and AJAX
to do this and update the <div>
.
I've added a button that saves the current <div>
's data and writes it into a .html` file and then downloads it, but it's not working well across browsers.
In Chrome this works:
$("#save").click(function () {
$('<a/>').attr({
download: 'export.html',
href: "data:text/html," + $('#result').html()
})[0].click()
});
But it doesn't work in IE11, Firefox or Edge, it fails to do anything. In Safari it works but changes the current active page to export.html
instead of downloading the export.html
file.
Is there a way to do this that will work across browsers. Have the <div>
output written to a html file and have it downloaded?
Thanks.