The script file and the jsfile reside together on an Apache homepage server. In the head section of index.html we have
<script type="text/javascript" src="someurl/jsfile.js"></script/>
And in the scriptfile we refer to jsfile by
function init_disp() {array_len = jsfile.length...
Running the scriptfile with or without someurl produces an "'jsfile' is undefined" error. Is there a problem here, or if the server software is blocking the script, does it do it by nulling the variables?
Using IE11 with enhance protect and 64 bit enhance protect, 64 bit Java. Edit: The entire scriptfile (not my own) is this:
addEvent(window,"load",init_disp);
addEvent(document,"click",show_init);
// function to add an event listener
function addEvent(o,e,f) {
if (o.addEventListener) {
o.addEventListener(e,f,false);
return true;
}
else if (o.attachEvent) {
return o.attachEvent("on"+e,f);
}
else {
return false;
}
}
// integer "random()"
function rand (n)
{
return (Math.floor( Math.random ()*n));
}
// BEGIN customization settings
var char_pause = 60; // pause on each character, milliseconds
var quote_pause = 8000; // pause to show complete quote, milliseconds
// END customization settings
var quoteindex;
var quote,attribution;
var pos;
var box;
var array_len;
var quote_len,attrib_len;
var interval = null;
var busy;
var cursor_span = "<span class=\"quotefont quotecursor\">";
var hide_span = "<span class=\"quotefont hidecolor\">"
var attr_div = "<p></p><div class=\"quotefont attrib\">";
function init_disp() {
array_len = jsfile.length;
box = document.getElementById("quotebox");
quoteindex = rand(array_len);
show_init();
}
function show_init() {
busy = false;
clearInterval(interval);
quote_array = jsfile[quoteindex].split("\t");
quote = quote_array[0];
attribution = quote_array[1];
quote_len = quote.length;
attrib_len = attribution.length;
quoteindex = (quoteindex+1) % array_len;
pos = 0;
interval = setInterval('show_quote()',char_pause);
}
function show_quote() {
pos++;
if(!busy) {
busy = true;
if(pos <= quote_len) {
box.innerHTML = quote.substring(0,pos) +
cursor_span +
quote.substring(pos,pos+1) +
"</span>" +
hide_span +
quote.substring(pos+1) +
"</span>";
}
busy = false;
}
if(pos > quote_len) {
pos = 0;
clearInterval(interval);
interval = setInterval('show_attr()',char_pause);
}
}
function show_attr() {
pos++;
if(!busy) {
busy = true;
if(pos <= attrib_len) {
var attr = attribution.substring(0,pos);
box.innerHTML = quote + attr_div + attr + "</div>";
}
busy = false;
}
if(pos > attrib_len) {
clearInterval(interval);
interval = setInterval('show_init()',quote_pause);
}
}