3

With vanilla JavaScript, I would do the following to add an h1 tag to the iframe body:

var doc = document.getElementById('iframe').contentWindow.document;
doc.write('<h1>Hello</h1>');

How can I do this with CycleJS?

m59
  • 43,214
  • 14
  • 119
  • 136
Nurlan Mirzayev
  • 1,120
  • 1
  • 7
  • 15

1 Answers1

2

HTML5 introduces the iframe attribute srcdoc that takes a string of HTML:

import {iframe, makeDOMDriver} from '@cycle/dom';

// later

iframe({attrs: {srcdoc: '<h1>Hello</h1>'}})

Apparently this does not work in IE or Edge without a polyfill, as mentioned here.


Of course there's the old trusty:

iframe({attrs: {src: 'myiframe.html'}})
Community
  • 1
  • 1
bloodyKnuckles
  • 11,551
  • 3
  • 29
  • 37