I want to handle click
event on an iframe
with a handler that gets the iframe
’s id as parameter.
I’m able to add an onClick
event handler via JavaScript as follows and it works fine:
iframe.document.addEventListener('click', clic, false);
But in this case I’m unable to pass a parameter to clic()
. I tried to print this.id
in clic()
but no result.
onClick
HTML attribute does not work at all, the handler is not called.
<html>
<head>
<script type="text/javascript">
function def() {
myFrame.document.designMode = 'on';
}
function clic(id) {
alert(id);
}
</script>
</head>
<body onLoad="def()">
<iframe id="myFrame" border="0" onClick="clic(this.id)"></iframe>
</body></html>
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…