上面的screengrab来自Firefox.光标悬停在图像左侧的黄点上.这是< img>元素(实际上它是一个图像与包含单个圆形< area>元素的图像映射,但我认为这种区别是不重要的)已经在
JavaScript中创建和设置样式,包括应用title属性(通过切割构造)和胶合弦).我怎样才能让它表现出来并显示出预定的角色,而不是& ndash;?它适用于innerHTML(左上角的文本“Barrow-In-Furness”是一个div,也是使用JavaScript创建的,以及它的innerHTML集.)
编辑:回答Domenic的问题:这是构建和应用title属性的JavaScript函数(除了执行其他作业):
var StyleLinkMarker = function (LinkNumber,EltA,EltI) { var AltText = LocationName[LinkStart[LinkNumber]] + " to " + LocationName[LinkEnd[LinkNumber]]; if (!EltA) { EltA = document.getElementById("link_marker_area" + LinkNumber); EltI = document.getElementById("link_marker_img" + LinkNumber); } if (LinkStatus[LinkNumber] === 9) { var CanBuyLinkCode = BoardPreviewmode ? 0 : CanBuyLink(LinkNumber); if (CanBuyLinkCode === 0) { EltI.src = ImagePath + "icon-buylink-yes.png"; AltText += " (you can buy this " + LinkAltTextDescription + ")"; } else { EltI.src = ImagePath + "icon-buylink-no.png"; AltText += " (you cannot buy this " + LinkAltTextDescription; AltText += CanBuyLinkCode === 1 ? ",because you aren't connected to it)" : ",because you would have to buy coal from the Demand Track,and you can't afford to do that)"; } } else if ( LinkStatus[LinkNumber] === 8 || (LinkStatus[LinkNumber] >= 0 && LinkStatus[LinkNumber] <= 4) ) { EltI.src = ImagePath + "i" + LinkStatus[LinkNumber] + ".png"; if (LinkStatus[LinkNumber] === 8) { AltText += " (orphan " + LinkAltTextDescription + ")"; } else { AltText += " (" + LinkAltTextDescription + " owned by " + PersonReference(LinkStatus[LinkNumber]) + ")"; } } else { throw "Unexpected Link Status"; } EltA.alt = AltText; EltA.title = AltText; };
LocationName如下:
var LocationName = [ "Barrow–In–Furness","Birkenhead","Blackburn","Blackpool","Bolton","Burnley","Bury","Colne","Ellesmere Port","Fleetwood","Lancaster","Liverpool","Macclesfield","Manchester","The Midlands","Northwich","Oldham","Preston","Rochdale","Scotland","Southport","Stockport","Warrington & Runcorn","Wigan","Yorkshire" ];