Hello,
I am trying take out my Javascript code from the <head> section of my source code and use external .js files.
The javascript works fine when in my <head> but when I place it in an external .js file I get this error:
Line 25
Char 1
Error Unterminated comment
URL file://C:
I have the correct path to the .js file and am using:
<script src="customer.js"></script>
in the <body> to call the script.
I know the error is "Unterminated comment" on line 25 but there is no line 25 in the external .js file. Here is the exact external file:
var theImages = new Array()
theImages[0] = 'theImages[1] = 'theImages[2] = 'theImages[3] = 'theImages[4] = 'theImages[5] = '
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer = new Image()
preBuffer.src = theImages
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
Is there something I'm doing wrong here? I would really appreciate some help. I've looked at this and tried different things so long, my eyes are crossed!
Thank you!
Vickie
I am trying take out my Javascript code from the <head> section of my source code and use external .js files.
The javascript works fine when in my <head> but when I place it in an external .js file I get this error:
Line 25
Char 1
Error Unterminated comment
URL file://C:
I have the correct path to the .js file and am using:
<script src="customer.js"></script>
in the <body> to call the script.
I know the error is "Unterminated comment" on line 25 but there is no line 25 in the external .js file. Here is the exact external file:
var theImages = new Array()
theImages[0] = 'theImages[1] = 'theImages[2] = 'theImages[3] = 'theImages[4] = 'theImages[5] = '
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer = new Image()
preBuffer.src = theImages
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
Is there something I'm doing wrong here? I would really appreciate some help. I've looked at this and tried different things so long, my eyes are crossed!
Thank you!
Vickie