I have an htmlString. And I am putting that string into an iframe. The code is
var iframe = document.createElement('iframe');
var html = '<html> <head></head> <body> //contents </body> </html>';
document.body.appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(html);
iframe.contentWindow.document.close();
Now what I want to do is insert a tag
<base href="some url" >
into the head of the htmlString. And then I want to append the iframe into the dom and write the htmlString into that iframe.
How to maniuplate the htmlString before inserting it into iframe?