I am refamilarizing myself with html. I started with the What is the DOM example at : https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction#What_is_the_DOM
in the section: Testing the DOM API. -----> CODE COPIED BELOW
I copied this text into a document. Saved it as html. Verified the file is a HTML by checking the properties on the file.
When open in Mozilla browser, it shows the code instead of the rendering of the text and buttons as expected. Javascript is enabled on my browser
What do I need to do to get the html to “run”?
<html>
<head>
<title>DOM Tests</title>
<script type="application/javascript">
function setBodyAttr(attr, value){
if (document.body) eval('document.body.'+attr+'="'+value+'"');
else notSupported();
}
</script>
</head>
<body>
<div style="margin: .5in; height: 400;">
<p><b><tt>text</tt></b></p>
<form>
<select onChange="setBodyAttr('text',
this.options[this.selectedIndex].value);">
<option value="black">black
<option value="darkblue">darkblue
</select>
<p><b><tt>bgColor</tt></b></p>
<select onChange="setBodyAttr('bgColor',
this.options[this.selectedIndex].value);">
<option value="white">white
<option value="lightgrey">gray
</select>
<p><b><tt>link</tt></b></p>
<select onChange="setBodyAttr('link',
this.options[this.selectedIndex].value);">
<option value="blue">blue
<option value="green">green
</select> <small>
<a href="http://www.brownhen.com/dom_api_top.html" id="sample">
(sample link)</a></small><br>
</form>
<form>
<input type="button" value="version" onclick="ver()" />
</form>
</div>
</body>
</html>