将鼠标悬停在iFrame上

时间:2014-08-01 03:04:09

标签: javascript iframe

当用户将鼠标悬停在内联框架上时,代码应显示从数组中获取的摘要。错字一直发生在我身上,但如果代码本身不正确,我想知道原因。

function setupFrame() {
    var allAreas = document.getElementsByTagName("area");
    for (i=0;i<allAreas.length;i++){
        allAreas[i].index = [i];
        allAreas[i].onmouseover = writeFrame();
        allAreas[i].onmouseout = clearFrame();
    }
}

function writeFrame() {
    var areaIndex = this.index;
    var frameWin = document.getElementById("parts");
    var frameDoc = frameWin.contentWindow.document;
    frameDoc.getElementById("docTitle").innerHTML = title[areaIndex].value;
    frameDoc.getElementById("docSummary").innerHTML = summary[areaIndex].value;
}

function clearFrame() {
    var areaIndex = this.index;
    var frameWin = document.getElementById("parts");
    var frameDoc = frameWin.contentWindow.document;
    frameDoc.getElementById("docTitle").innerHTML = "";
    frameDoc.getElementById("docSummary").innerHTML = "";
}

0 个答案:

没有答案