Rohit Bajaj
asked on
Why datauri in iframe should be encoded
Hi,
I have the following js :
One is that i encode it and use it in iframe src... other way is i directly use the whole html string in srcdoc.
Which is the preferable way ?
Also why do we need to encode data when specifying data URIs ?
Thanks
I have the following js :
var contentCss = '<link href="https://cdn.ckeditor.com/4.5.6/full/contents.css" rel="stylesheet" type="text/css"/>';
var iframeSrc= contentCss + '<body><div id="textArea" class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders">' + noteBody + '</div><body>';
document.getElementById('iframe').src = 'data:text/html;base64,' + btoa(iframeSrc);
// document.getElementById('iframe').srcdoc = iframeSrc;
There are two possible ways i can render this iframeSrc string... which is actually an html string..One is that i encode it and use it in iframe src... other way is i directly use the whole html string in srcdoc.
Which is the preferable way ?
Also why do we need to encode data when specifying data URIs ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.