javascript - How to save web contents to another html file -
i'm new javascript , electron projects. have small task run webpage in have "download" button, if hit button have contents , sources code downloaded current page. here sample work :
browser.js
onload = function() { var webview = document.queryselector('webview'); dolayout(); document.queryselector('#back').onclick = function() { webview.goback(); }; document.queryselector('#download').onclick = function() { var urlstr = webview.geturl() alert(urlstr) // alert(webview.getwebcontents()); }; }
currently able url in alert view, i'm not able webpage contents
note: please give solution in javascript not in jquery
finally simple code helped me download html file
var htmlcontent = [""]; var bl = new blob(htmlcontent, {type: "text/html"}); var = document.createelement("a"); a.href = urlstr; a.download = "new.html"; a.hidden = true; document.body.appendchild(a); a.innerhtml = "something random - nobody see this, doesn't matter put here"; a.click()
Comments
Post a Comment