I need to a save certain part of my web page as an html package. I can only download the plain html but I don't have any idea how to include external style sheets and images along with it. See my code below.
function downloadInnerHtml(filename, elId, mimeType) {
var elHtml = document.getElementById(elId).innerHTML;
var link = document.createElement('a');
mimeType = mimeType || 'text/plain';
link.setAttribute('download', filename);
link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
link.click();
}
Thanks in advance.
Comments
Post a Comment