Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从父框架更改 iframe 中表单的提交功能。下面的代码应该做到这一点,但没有任何结果。并且在 chrome 的调试器中没有显示错误。怎么了?
<iframe src="test.php" id="frame"></iframe> <script type="text/javascript"> $("#frame").contents().find("form").submit(function(){ return true; }); </script>
确保在加载此 iframe 的内容后,通过将调用包装在.load回调中来操作它的 DOM:
.load
<iframe src="test.php" id="frame"></iframe> <script type="text/javascript"> $('#frame').load(function() { $(this).contents().find('form').submit(function() { return false; }); }); </script>