Flash元素内部的href



使用以下代码:

<a href="/someurl">
  <div class='mydiv' 
   onMouseOver="document.getElementById('myid').sendEvent('play');"
   onMouseOut="document.getElementById('myid').sendEvent('stop');">
    <div id='myid'></div>
    <script type="text/javascript">
      flashplayer.init('myid');
    </script>
  </div>
</a>

触发play()和stop()按预期工作,但是href没有做太多,因为点击事件被发送到flashplayer,而不是跟随超链接。

我在页面上有几个这样的flash播放器,我正试图找到一种方法来"激活"href onClick并尊重<a href="">结构中指定的url。具体来说,我在IE8中遇到了困难。

我如何使用html/javascript做到这一点?

*编辑:

在遇到javascript的onclick事件在flash对象后,我设法接近我所追求的。使用onmousedown事件,我可以触发javascript时,点击我的覆盖div。什么是一个很好的通用方法来读取父href url和location.href='/myparenturl';" style="cursor: pointer; ?

读取父url和issue的通用方法是什么" style="cursor: pointer;

?

为什么要监视div上的onmousedown ?我做了一个jsfiddle,演示了页面上每个锚标记的链接属性的提取,只是用window.location(link)代替alert(link)。你也可以使用getElementsByClassName代替getElementsByTagName,如果只有一些链接,你想要修复。

var anchors = document.getElementsByTagName('a');
for(i = 0; i <= anchors.length; i++) {
    var anchor = anchors[i],
        link = anchor.getAttribute('href'),
        div = anchor.childNodes[0];
    div.onmousedown = function() {
        alert(link);
    }
}

最新更新