What's wrong with this code?
var divarray = document.getElementById("yui-main").getElementsByTagName("div");
var articleHTML = array();
var absHTML;
var keyHTML;
var bodyHTML = array();
var i = 0;
for ( var j in divarray) {
if(divarray[i].className == "articleBody"){
alert("found");
articleHTML = divarray[i];
break;
}
bodyHTML[i] = '';
if(articleHTML[i].className == "issueMiniFeature"){continue;}
if(articleHTML[i].className == "abstract"){absHTML = articleHTML[i]; continue;}
if(articleHTML[i].className == "journalKeywords"){keyHTML = articleHTML[i]; continue;}
bodyHTML[i] = articleHTML[i];
i++;
}
This is the error I am getting:
ReferenceError: array is not defined
I am using Google Chrome if it helps any.
Note! Javascript IS case sensitive you have to use upper-case A in word Array.
var myarr = new array(); //THIS IS WRONG! and will result in error not defined
So these are the correct ways:
var myarr = new Array(); //THIS IS CORRECT (note the "big" A) :)
var myarr = []; //and this is correct too
It's not php - you should use
var variable_name = new Array()
or even better
var variable_name = []
You first need to define
var divarray = new Array();
var articleHTML = new Array();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With