我已经搜索了此博客和其他博客中提供的答案,但没有任何解决方案。非常感谢您的帮助。
我有一个 onmousemove 事件,它正在执行要触发的事件列表中的第一项,但不会执行第二项。
document.getElementById("map_image_africa").onmousemove = maps.redraw; learnPanel.redraw;
该问题似乎不是特定于浏览器的;它发生在 Chrome 和 Safari 中。还没试过火狐。
在 Chrome 中,我可以打开浏览器的控制台并执行learnPanel.redraw();
它,它可以按预期工作。此外,如果我在 onmouseover 事件中的 maps.redraw 和 learnPanel.redraw 语句之间放置一条警告语句,则警告将按预期执行。
learnPanel 对象是使用下面的代码创建的
LearnPanel.prototype = new Panel();
LearnPanel.prototype.constructor = LearnPanel;
function LearnPanel() {
}
LearnPanel.prototype.draw = function() {
var br_element = document.createElement("br");
/* country name */
if(this.isCountryNamesSelected === "yes") {
var temp_label;
temp_label = document.createElement("label");
temp_label.classList.add('quiz_question_heading_label');
temp_label.innerHTML = "Country: ";
this.flagColumnTab.appendChild(temp_label);
this.labelCountryName = document.createElement("label");
this.labelCountryName.id = "country_name";
this.labelCountryName.classList.add('quiz_question_label');
this.flagColumnTab.appendChild(this.labelCountryName);
this.flagColumnTab.appendChild(document.createElement("br"));
}
/* capital */
if(this.isCapitalNamesSelected === "yes") {
var temp_label;
temp_label = document.createElement("label");
temp_label.classList.add('quiz_question_heading_label');
temp_label.innerHTML = "Capital: ";
this.flagColumnTab.appendChild(temp_label);
this.labelCapitalName = document.createElement("label");
this.labelCapitalName.id = "capital";
this.labelCapitalName.classList.add('quiz_question_label');
this.flagColumnTab.appendChild(this.labelCapitalName);
this.flagColumnTab.appendChild(document.createElement("br"));
}
/* flag */
if(this.isCountryFlagsSelected === "yes") {
this.flagImage = document.createElement("img");
this.flagImage.id = "flag_image";
this.flagImage.src = "/images/flags/_flag.jpeg";
this.flagImage.alt = "flag logo";
this.flagColumnTab.appendChild(this.flagImage);
this.flagColumnTab.appendChild(document.createElement("br"));
this.flagColumnTab.appendChild(document.createElement("br"));
}
}
LearnPanel.prototype.redraw = function() {
alert('redrawing learnPanel');
/* country name */
if(learnPanel.isCountryNamesSelected === "yes") {
learnPanel.labelCountryName.innerHTML = maps.getCurrentDisplayCountryDown();
}
/* capital */
if(learnPanel.isCapitalNamesSelected === "yes") {
learnPanel.labelCapitalName.innerHTML = maps.getCurrentCountryCapitalDown();
}
/* flag */
if(learnPanel.isCountryFlagsSelected === "yes") {
learnPanel.flagImage.src = "/images/flags/" + maps.getCurrentFlagDown() + "_flag.jpeg";
learnPanel.flagImage.alt = "flag of " + maps.getCurrentFlagDown();
}
/* head of state */
/* famous landmark */
}
learnPanel = new LearnPanel();
在此先感谢您的帮助!