[英]Div has onclick function but the iframe inside the div is not clickable
我有一个div
,在这个div
中有一个 function 和iframe
,但是我的iframe
是不可点击的。 有没有办法让iframe
可点击并触发相同的事件或 function 作为这个iframe
所在的div
? 我将非常感谢任何建议。 谢谢
<div id="t1" onclick="myFunction(this, 'test', '')" class="button-hyperlink">
<h5>Testing</h5>
<h6>
<iframe id="content_iframe3" src="test.html" scrolling="no" frameborder="0"
height="30px" width="200px" name="target-iframe"></iframe>
</h6>
</div>
Function
function myFunction(divid, link) {
this.clear();
divid.style.background = "blue";
//some conditions
}
function clear() {
for (var i = 0; i < divItems.length; i++) {
var item = divItems[i];
item.style.backgroundColor = 'red';
}
}
这段代码怎么样。 (它与您的myFunction
略有不同。)
<div id="t1" onclick="myFunction('t1')" class="button-hyperlink">
<h5>Testing</h5>
<h6>
<iframe id="content_iframe3" src="test.html" scrolling="no" frameborder="0"
height="30px" width="200px" name="target-iframe"></iframe>
</h6>
</div>
function myFunction(divid) {
var div=document.getElementById(divid);
div.style.background = "blue";
}
window.onload=function () {
var f=document.querySelector("#content_iframe3");
f.contentWindow.addEventListener("click", function () {
myFunction("t1");
} );
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.