0

I generated html file from base64 format using javascript after that i'm open that file in new tab , and i did that with succes , now i would like to apply stylesheet on my file.

here is my code to generate and open the file :

//s_utf8String is result of the content that i use to generate the file.

var binary = atob(a.s_utf8String.replace(/\s/g, ''));
var len = binary.length;
var buffer = new ArrayBuffer(len);
var view = new Uint8Array(buffer);
for (var i = 0; i < len; i++) 
{
view[i] = binary.charCodeAt(i);
 }
var blob = new Blob([view], {type: "application"});
                var url = URL.createObjectURL(blob);               
                window.open(url);

Any one have an idea how i can add the stylesheet

Marooweb
  • 476
  • 3
  • 8
  • 21
  • Is this javascript sript is in a js file or in an html file? – Richard Feb 11 '19 at 13:59
  • 1
    Possible duplicate of [How to load up CSS files using Javascript?](https://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript) – Richard Feb 11 '19 at 14:01
  • You probably want to inject the styles as part of the blob/code you are turning in to a url. You could also try keeping a reference to the new window and if it is in the same domain you might be able to access the dom and inject css that way, but that way it fragile if it would even work at all. – lemieuxster Feb 11 '19 at 15:50

0 Answers0