Jay Braun
8/25/2015 6:45:00 PM
I have a web page that originally had embedded JavaScript within a script section, and it worked fine when served up with a simple http server.
I now want to put my JavaScript, which manipulates SVG elements, in separate files, and as a first try, I put it all in a singe .js file:
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Some Graphics With SVG</title>
<head>
<meta http-equiv="refresh" content="5">
<style>
#svgContainer {
width: 2188px;
height: 1312px;
background-color: "white";
}
</style>
<script src="all.js"></script>
</head>
<body onload="resagui()">
<div id="svgContainer"></div>
</body>
I should note that the JavaScript function resagui appears at the top of all.js:
function resagui() {
...
}
Everything works great when I test this locally and view the page with file:///... from my browser. But when I try http://ipaddress:port it does not work. (A simple server application serves up the file index.html).
I know that this is not a network issue, as the html file with embedded JavaScript works fine when I try http://ipaddress:port
My Firefox browser console provides two errors:
SyntaxError: expected expression, got '<' and ReferenceError: resagui is not defined
The html looks well formed, and there is no '<' character in my .js file.
*** Please note that this is not a website per se. I have an application that generates and updates SVG descriptions of objects in JavaScript, and is attempting to specify, as the "URL" of the src attribute, a files in the same directory. Maybe this is where I am going wrong.
Thanks for any insight you can provide.
Jay