フォームのポップアップ ウィンドウを送信したい。
Parent.html
<form class="myform" name="forms" onsubmit="return submit_form()" >
</form>
<form class="myform" name="forms" >
</form>
<form class="myform" name="forms" >
</form>
Parent.html JAVASCRIPT
<script>
function submit_form()
{
console.log(0);
return false;
}
window.onload = function(){
//attach eventListner
document.getElementsByName("forms").addEventListner("submit",function(){
console.log(1);
return false;
},false);
//IN JQUERY
$(document).ready(function(){
$(".myform").live("submit",function(){
console.log(2);return false;
});
});
};
</script>
window.open
メソッドを使用して新しいポップアップ ウィンドウを開いています。
次のようにポップアップウィンドウからフォームを送信しようとしています...
var docs = window.opener.document ;
//first try to submit through jQuery
$(docs).find("form").eq(0).submit(); // it will work all browsers except IE8
or
docs.getElementsByTagName("form")[0].submit(); // it will work everywhere ,but on parent window the form will submitted by default (no attached events will work)
助けてください ..
ありがとう。