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?
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?
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'}})