0
我創建了一個用於爲網頁添加橫幅的greasemonkey腳本。首先,我從簡單的圖像開始,工作得很好。然後我想添加一個圖像映射來創建工具欄的效果。頁面加載,腳本執行,在螢火蟲中看起來不錯,但沒有拾取點擊。如果我添加一個onclick圖片,圖片會獲得點擊。不是該地區。 任何指導讚賞圖片地圖不能在greasemonkey腳本中工作
var input=document.createElement("img");
input.src="http://.../banner_gh.png";
var map = document.createElement("map");
map.name = "barMap";
map.id = "barMap";
var trialArea = document.createElement("area");
trialArea.shape = "rect";
trialArea.coords = "675,0,766,50";
trialArea.href = "https://apps..../.../foo";
trialArea.title = "Start Trial";
trialArea.alt = "Start Trial";
trialArea.onclick = startTrial;
map.appendChild(trialArea);
input.useMap = "#barMap";
// inserting the image in the right place in my page
var container = document.getElementById("overview");
container.parentNode.insertBefore(input,container);
function startTrial()
{
document.location.href = "https://apps..../.../foo";
}
使用Firefox 17,和Greasemonkey的1.11 感謝
因此,這些區域已附加到地圖上,我們需要確保將地圖附加到DOM上 - 謝謝! – rustyDeveloper