這裏發生了什麼如何解決 - 它被渲染後
- 頁面加載之後,javascript中的底層代碼
- 的XML讀取XML,包含了一些領域的DIV元素閃爍/立即消失-ids,和相應的內容,當鼠標懸停在字段ID中的彈出窗口來顯示列出
我的代碼生成一束彈出窗口的作爲DIV元素與樣式
.render{
background-color: #fffc80;
border: .1em solid rgb(200, 128, 0);
padding-left: 2px;
padding-right: 2px;
z-index: 1000;
}
.hide{
display:none;
}
所有創建的彈出窗口都附加到根元素。
編輯:新增的腳本片段
事件處理程序連接如下
// instantiate a div element
var myDiv = document.createElement('div');
// generate an ID
myDiv.id = generatePopupId(getFieldId());
// attach the content from the XML into the new div element
myDiv.innerHTML = getPopupContent();
// apply mouseover/out handlers to the main element
document.getElementById(getFieldId()).onmouseover = function(){
showPopup(generatePopupId(getFieldId()));
};
document.getElementById(getFieldId()).onmouseout = function(){
hidePopup(generatePopupId(getFieldId()));
};
// read the X coordinate of the present position of the mouse
function getX(){
var e = window.event;
posX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
return posX;
}
// read the Y coordinate of the present position of the mouse
function getY(){
var e = window.event;
posY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
return posY;
}
// Show the popup element at the current mouse location
function showPopup(popupId){
var posX = getX();
var posY = getY();
var poppyElement = document.getElementById(popupId);
poppyElement.className = 'render';
poppyElement.style.left = posX;
poppyElement.style.top = poxY;
poppyElement.style.position = 'absolute';
poppyElement.style.display = '';
}
// hide the popup element
function hidePopup(popupId){
var poppyElement = document.getElementById(popupId);
poppyElement.className = 'hide';
}
我的問題是 - 爲什麼元素閃光燈,並立即消失,而不是掛在鼠標移開事件?
問候, 阿布舍克巴克
提供了更多的代碼。你如何附加你的事件處理程序? – 2009-11-30 11:38:37
已更新帖子以攜帶我已有的腳本。想想任何人? – Everyone 2009-12-01 05:16:53