diff --git a/src/view.js b/src/view.js index 1842d6a..f19a195 100644 --- a/src/view.js +++ b/src/view.js @@ -40,15 +40,17 @@ function drawDeviceFrame(id) { - - ${generateBodyHTML(d)} - `; + d.contentBodyElement = document.createElement('body'); + + d.contentBodyElement.innerHTML = generateBodyHTML(d); + $deviceDrawArea.setAttribute('class', `${d.type} draw-area`); $deviceDrawArea.contentWindow.document.open(); $deviceDrawArea.contentWindow.document.write(str); + $deviceDrawArea.contentWindow.document.body = d.contentBodyElement; $deviceDrawArea.contentWindow.document.close(); $deviceDrawArea.contentWindow.document.onclick = function (e) { switchDevice(d.id); @@ -98,7 +100,6 @@ function generateBodyHTML(d) { module.exports.draw = function draw(device) { const d = device; - const $deviceDrawArea = document.getElementById(`device-${d.id}-draw-area`); if (device.drawTimeout !== undefined) { clearTimeout(device.drawTimeout);