Hi i am continue getting undefined error in alert when i am trying to access my class veriable from out side of class, i have made a main class and then use prototype to add some object into my class which i want to access from anywhere by creating new class please help me
function initShell(){
XMLLoader.prototype.loadXML('xml/scq.xml', initShell.prototype.loadData);
alert(this.currentQue);
}
initShell.prototype.loadData = function(xmlRef){
this.currentQue = 0;
this.pageList = xmlRef.getElementsByTagName("mission");
}
var p1 = new initShell;
alert(p1.currentQue);
Try like this
Edit :
Working demo
// Define a class like this
function initShell(currentQue, pageList){
// Add object properties like this
this.currentQue= currentQue;
this.pageList= pageList;
}
// Add methods like this. All initShell objects will be able to invoke this
initShell.prototype.speak = function(){
alert("Value of currentQue is : " + this.currentQue);
};
// Instantiate new objects with 'new'
var initShellObj = new initShell("A", "B");
// Invoke methods like this
initShellObj.speak();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.