Rear Window
Rear Window lets you easily create iframes with HTML contents.
Simple Usage
var RW = require('rear-window');
var container = document.createElement('div');
document.body.appendChild(container);
var iframe = RW.create(container);
RW.update(iframe, '<h1>Sample Content</h1>');
RW.update(iframe, '<h1>New Content</h1><p>Overwrites existing content.</p>');
Options
Rear Window also supports providing options for:
- inserting
<body>
content immediately - setting iframe attributes
- adding
<link rel="stylesheet" />
tags to the <head>
of the iframe - adding
<style>
tags to the <head>
of the iframe
var RW = window.RW;
var container = document.createElement('div');
document.body.appendChild(container);
var options = {
styleString: 'body { color: #ff0000; }',
styleLink: 'styles/iframe.css',
content: '<h1>Sample Content</h1><p>No need to call update()</p>',
iframeAttributes: {
classString: 'iframe-noborder full-height etc'
id: 'one-and-only-iframe',
'data-foo': 'bar'
}
};
var iframe = RW.create(container);
RW.update(iframe, '<h1>Sample Content</h1>');