【发布时间】:2015-07-31 17:51:39
【问题描述】:
当我的表单输入发生更改时,我尝试执行一项操作,但它不起作用。我的表单是动态添加的:
<iframe onload="javascript:parent.scrollTo(0,0);"
height="447" allowTransparency="true" frameborder="0" scrolling="no"
style="width:100%;border:none" src="https://emu.edu/machform/embed.php?id=38142"
title="Form"><a href="https://emu.edu/machform/view.php?id=38142" title="Form">Form</a>
</iframe>
这是我的 jQuery:
function doThis() {
alert("Form changed!");
}
$("iframe").on('change', 'input', doThis);
【问题讨论】:
-
主页和iframe是否在同一个域中?可以在这里看看:stackoverflow.com/questions/364952/…
-
这是一个安全错误:
Both frames are sandboxed and lack the "allow-same-origin" flag。查看控制台。 -
你可以试试
$("iframe").contents().find("input").on("change", doThis);吗? -
Vidul,我想用 jsfiddle 重新创建问题是行不通的。即使起源匹配,它也不起作用。
-
czheo,这似乎并没有改变任何东西(双关语)。
标签: javascript jquery html events onchange