两个链接重叠

时间:2013-04-01 10:27:14

标签: html hyperlink overlapping

我遇到了HTML问题。

我有一个包含链接图像的链接div。当我点击图像时,我会同时打开(图像和div)链接,而我只想打开图像。

我怎样才能让它发挥作用?我需要当我点击整个div时,除了图像区域之外,我会看到div的链接,否则就会出现在图像上。

提前致谢, 阿莱西奥

2 个答案:

答案 0 :(得分:0)

你可以这样做

<div id="mydiv" onclick="window.location.href=('Somepage.aspx')">
  Some text to fill the space... blah blah blah<br />
  <img id="myimg" onclick="window.location.href=('AnotherPage.html')" src="thisphoto.gif" />
</div>

更新

您可以添加脚本以取消气泡,然后转发到所需的页面 它可能是两三行

<script type="text/vbscript" id="CancelMyBubble">
  function CancelMyBubble(link)
    window.event.cancelBubble = true
    window.location.href=link
  end function
</script>


<div id="mydiv" onclick="window.location.href=('Somepage.aspx')">
  Some text to fill the space... blah blah blah<br />
  <img id="myimg" src="shape1.jpg" onclick="CancelMyBubble('AnotherPage.html')" />
</div>

答案 1 :(得分:0)

你可以这样做: -

function func1()
{
window.location.href="http://www.google.com";

}

function func2()
{
window.location.href="http://www.yahoo.com";

}

HTML CODE

 <div id="divid" >
 <div onclick="func1()"> Some text to fill the space... blah blah blah</span></div>
<img id="imgid" onclick="func2()" src="SOMEIMAGE" />
</div>