我已經通過本博客和其他人提供的答案進行搜索,沒有任何解決方案。非常感謝幫助。onmousemove不發作的事件
我有一個onmousemove事件正在執行要觸發的事件列表中的第一個項目,但不會執行第二個項目。 document.getElementById("map_image_africa").onmousemove = maps.redraw; learnPanel.redraw;
該問題似乎並不是瀏覽器特定的;它出現在Chrome和Safari中。還沒有嘗試過Firefox。
在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();
感謝您的幫助!
感謝明確的答案 - 這解決了這個問題。我也接受了關於eventListeners的建議。謝謝! – LetsPlayGlobalGames 2013-03-23 01:15:20
很高興知道它有幫助,感謝您報告回來! – 2013-03-23 04:23:16