I want to change the submit function of form in iframe from the parent frame. The following code should do that, but nothing hapen. And no error shown in chrome's debugger. What is wrong?
<iframe src="test.php" id="frame"></iframe>
<script type="text/javascript">
$("#frame").contents().find("form").submit(function(){
return true;
});
</script>
Make sure that you are manipulating the DOM of this iframe once its contents has been loaded by wrapping your call inside a
.load
callback:You cannot manipulate any of the actions of an iFrame through JS.
That is the whole point of an iFrame.
Try today, try forever. It cannot be done. That is why Facebook "like" buttons and many other big-league items are always contained withing iFrames, so you cannot change what they look like or what they do.