I'm using Angular 6 for my project, in my index page I'm binding data and submit it to db, I want to submit whole html page with bonded data to db as string.
Can I know how to convert html page to base 64 string?
I'm using Angular 6 for my project, in my index page I'm binding data and submit it to db, I want to submit whole html page with bonded data to db as string.
Can I know how to convert html page to base 64 string?
You can get you Markup as a string with,
var markup = document.documentElement.innerHTML;
And then convert that string to base64 using btoa()
like this,
var encoded = window.btoa(markup);
Or if you get UTF8, use this,
var encoded = window.btoa(unescape(encodeURIComponent(markup)));
You can get the HTML as string of any website with
window.document.documentElement.innerHTML