# JS-Interpreter DOM Demo

The JS-Interpreter is a sandbox, it doesn't have any access to the DOM -- unless you provide your own interface functions. This demo creates the following interfaces:

- `document.getElementById(id)`
- `document.createElement(tagName)`
- `document.createTextNode(text)`
- `Node.prototype.hasChildNodes()`
- `Node.prototype.removeChild(node)`
- `Node.prototype.firstChild/lastChild/parentNode`
- `Element.prototype.appendChild(node)`
- `Element.prototype.innerHTML`

This minimal demo can be used as the basis for a more extensive interface. Expose as much of the DOM as you need, but be mindful of providing too much access. For example, granting the ability to set innerHTML enables interpreted code to write script tags. Open your browser's console for errors.

This div's ID is "banner":

var italics = document.createElement('i'); italics.appendChild(document.createTextNode('Hello from ')); italics.innerHTML += '<u>JS-Interpreter</u>'; document.getElementById('banner').appendChild(italics);

Back to the JS-Interpreter documentation.