Hey everyone,
I am trying reference an external JavaScript file on a page I am working on and Safari seems to have problems with it. However, Firefox displays the file fine... Could someone tell me what I am doing wrong?
---HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1 TRANSITIONAL//EN"
"http://www.w3.org/TR/xhtml11/DTDxhtml11.dtd">
<html>
<head>
<title>Example</tilte>
<script type="text/javascript" src="example.js"></script>
</head>
<body onload="process()">
Hello there, here's a list of colors being displayed with an external JS file: <br />
<div id="myDivElement" />
</body>
</html>
---END HTML
---JS FILE
function process()
{
//create the HTML code with JavaScript
var string;
string = "<ul>"
+ "<li>Black</li>"
+ "<li>Red</li>"
+ "<li>Green</li>"
+ "</ul>";
//obtain the a reference to the <div> element on the HTML page
myDiv = document.getElementById("myDivElement");
//Add content to the <div> element "myDivElement on the HTML page
myDiv.innerHTML = string;
}
---END JS FILE
Thanks for any and all help,
N
I am trying reference an external JavaScript file on a page I am working on and Safari seems to have problems with it. However, Firefox displays the file fine... Could someone tell me what I am doing wrong?
---HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1 TRANSITIONAL//EN"
"http://www.w3.org/TR/xhtml11/DTDxhtml11.dtd">
<html>
<head>
<title>Example</tilte>
<script type="text/javascript" src="example.js"></script>
</head>
<body onload="process()">
Hello there, here's a list of colors being displayed with an external JS file: <br />
<div id="myDivElement" />
</body>
</html>
---END HTML
---JS FILE
function process()
{
//create the HTML code with JavaScript
var string;
string = "<ul>"
+ "<li>Black</li>"
+ "<li>Red</li>"
+ "<li>Green</li>"
+ "</ul>";
//obtain the a reference to the <div> element on the HTML page
myDiv = document.getElementById("myDivElement");
//Add content to the <div> element "myDivElement on the HTML page
myDiv.innerHTML = string;
}
---END JS FILE
Thanks for any and all help,
N