Forum Moderators: open
var global = 5;
addEvent(window,"load",init);
addEvent(window,"load",getSingleVideoDetails);
function init(){
global=5+100;
}
function getSingleVideoDetails(){
alert(global);//returns 5
}
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
[edited by: DrDoc at 11:15 pm (utc) on Mar. 17, 2008]
init() will run first. If you remove this line: addEvent(window,"load",getSingleVideoDetails); ... and change your
init() function to: function init(){
global=5+100;
[b]getSingleVideoDetails();[/b]
} ... then it will work.
[edited by: DrDoc at 11:18 pm (utc) on Mar. 17, 2008]
var global = 5;
addEvent(window,"load",init);
addEvent(window,"load",getSingleVideoDetails);
function init(){
global=5+100;
}
function getSingleVideoDetails(){
alert(global);//returns 5
}
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
[edited by: DrDoc at 11:15 pm (utc) on Mar. 17, 2008]
init() will run first. If you remove this line: addEvent(window,"load",getSingleVideoDetails); ... and change your
init() function to: function init(){
global=5+100;
[b]getSingleVideoDetails();[/b]
} ... then it will work.
[edited by: DrDoc at 11:18 pm (utc) on Mar. 17, 2008]