I’m trying to execute a javascript file in my browser but the code is displayed and not actually executed. I’m using firefox and I made sure javascript is enabled. I tried using a .js extension and .shtml and both just display the code. The file is located in my apache htdocs folder and it’s version 2.2.
I’m trying to run this hello world code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="helloworld.js"></script>
</head>
<body>
<p id="hello"></p>
</body>
</html>
Here’s the javascript
document.getElementById('hello').innerHTML = 'hello world';
Any suggestions?
try something like this
helloworld.js