[英]Image map not working in greasemonkey script
I created a greasemonkey script where I add a banner to a web page. 我创建了lublessmonkey脚本,在其中将横幅添加到网页。 First I started with the plain image and worked fine.
首先,我从简单的图像开始,并且运行良好。 Then I wanted to add an image map to create the effect of a toolbar.
然后,我想添加一个图像贴图以创建工具栏的效果。 The page loads, the script executes, looks good in firebug, but not picking up the clicks.
页面加载,脚本执行,在萤火虫中看起来不错,但没有引起点击。 If I add an onclick to the image, the image gets the click.
如果我在图片上添加onclick,则图片会获得点击。 Not the area.
不是该地区。 Any guidance appreciated
任何指导表示赞赏
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";
}
Using Firefox 17, and Greasemonkey 1.11 thanks 使用Firefox 17和Greasemonkey 1.11,谢谢
It seems like you simply forget to insert your map into the page. 似乎您只是忘了将地图插入页面。 Try add
尝试添加
container.parentNode.insertBefore(map,container);
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.