横幅图像上的链接未在IE中被点击

时间:2013-03-24 10:53:56

标签: html css internet-explorer

我的网站上有宣传横幅。

HTML结构是这样的

<a href="#"><img src="#" usemap="abc"></img></a><map name="abc"><area ...></map>

实际代码:

<div id="promotion_banner" Style="position:fixed;right:0pt;top:25%;cursor: pointer;display:none;z-index:101;"> <a href="http://www.abc.com"> <img src="off-open-mar.png" alt="ABC" usemap="#hide_promo"></img> </a> <map name="hide_promo"> <area shape="rect" coords="20,235,42,260" id="hide_promotion" alt="text"> </map> </div>

当我点击Chrome或FireFox或Opera中的横幅或IE以外的任何其他浏览器时,它工作正常。

但是当我在IE中尝试同样的事情时,它不会点击。在悬停时,它显示相应的URL,但URL不可点击 您可以通过右键单击横幅或单击URL一次然后按Enter键来访问URL。

如果有人知道某事,请告诉我。

1 个答案:

答案 0 :(得分:0)

这应该可以在任何浏览器中完美运行:

<div id="promotion_banner"> 
<a href="2.html"> <img src="r.jpg" alt="ABC" usemap="#hide_promo" onclick="location.href='2.html'" style="cursor: hand;"/> </a> 
<map name="hide_promo"> 
    <area shape="rect" coords="20,235,42,260" id="hide_promotion" alt="text" /> 
</map> 
</div>

我在IE中测试了它并且它运行得很好。 由于兼容性问题,横幅图片上的链接没有被点击进入IE,所以我调用了javascript onclick函数:

 onclick="location.href='2.html'"

使其可点击。

Please note:我故意在两个地方提供了网址:

 (1)<a href="2.html"> 
 (2)"location.href='2.html'"

因为第二个 onclick="location.href='2.html'"受支持,仅适用于 IE

对于 IE 以外的所有浏览器( chrome,safari,firefox,opera ),<a href="2.html"><img...上的链接都可以使用。

棘手的解决方案,但适用于任何浏览器。