myXML.onLoad 是在加载数据之后发生的,myXML.ignoreWhite = true; myXML.onLoad = function()
{
ButtonLength=myXML.childNodes.length; //在这里ButtonLength=4
} <-- 这里仅仅是把function对象赋给myXML的onLoad属性而已,并没有运行//在这里ButtonLength=0 <-- 这个地方是先于myXML.onLoad运行的
{
ButtonLength=myXML.childNodes.length; //在这里ButtonLength=4
} <-- 这里仅仅是把function对象赋给myXML的onLoad属性而已,并没有运行//在这里ButtonLength=0 <-- 这个地方是先于myXML.onLoad运行的
alert(1)
myXML=new XML(); myXML.load("GeographicalNames.Xml");
alert(2)
myXML.ignoreWhite = true;
alert(3)
myXML.onLoad = function() {
alert(4)
ButtonLength=myXML.childNodes.length;
alert(5)
//在这里ButtonLength=4
}
alert(6)
//在这里ButtonLength=0