-1

I'm wanting to update an iframe with css in javascript. I know how to update the iframe body with the code below but is there a way to insert css into the head of the iframe?

Thanks David

var previewFrame = document.getElementById('previewFrame');
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;

preview.open();
preview.write('New Content');
preview.close();
David
  • 209
  • 4
  • 17

1 Answers1

-2

I think if you have iframe page under the same domain you should try this:

$("iframe").contents().find('head').append('<style type="text/css">' +'MY CSS IS HERE' + '</style>')
Krupal Shah
  • 8,949
  • 11
  • 57
  • 93