[英]flash element inside 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,而不是跟隨超鏈接。
我在頁面上有幾個這樣的 flashplayers,我正在嘗試找到一種方法來“激活”href onClick 並尊重<a href="">
構造中指定的 url。 具體來說,我在 IE8 中苦苦掙扎。
如何使用 html/javascript 執行此操作?
*編輯:
在遇到javascript onclick 事件發生在 flash object 之后,我設法接近了什么。 使用 onmousedown 事件,我可以在單擊覆蓋 div 時觸發 javascript。 什么是閱讀父 href url 並發出location.href='/myparenturl';" style="cursor: pointer;
?
什么是閱讀父 href url 並發出 location.href='/myparenturl';" style="cursor: pointer; ?
為什么要在 div 上觀看 onmousedown ? 我做了一個jsfiddle演示提取頁面上每個錨標簽的鏈接屬性,只需將alert(link)
替換為window.location(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);
}
}
更新:插入代碼片段
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.