HTML file:
<html>
<head>
<title></title>
<script lanuage='javascript' ;src="test.js"></script>
</head>
<script language="javascript">
test1(1, 2);
</script>
<body>
<p id="t">test page for p server</p>
</body>
</html>
test.js file:
function test1(x, y) {
var x, y;
z = x + y
document.write('z: ', z)
return (z)
}
error appearing on the browser is Uncaught ReferenceError: test1 is not defined
This error does not come when I have the function inside the .html file. I want to have the function in the linked .js and was wondering how I could resolve this issue.
2
Answers
you can try to change
test1(1, 2)); with test1(1, 2);
It doesn’t work because
;src
is not a valid attributeReplace
with