フォーム データを 2 つの異なる場所に同時に投稿したい状況があります。私は場所を制御できず、それらはクロスドメインです。iframe を使用して、ここで以前の投稿を見つけましたが、今は見つけられず、組み込みました。最初のものには毎回提出しますが、2 番目のものは 25% の確率でしか提出されません。すべての主要なブラウザーでより確実に動作するようにする必要があります。ajax を使用してみましたが、このフォーラムで提示された多くの解決策を試して IE でクロスドメインを動作させることができませんでした。ありがとう。エド
<form name="myForm" method="post" action="http://www.firstwebsite.com" onsubmit="return submit2nd()" >
<input type="email" name="email" value='' />
<input type="submit" name="submit" />
</form>
<script>
function submit2nd(){
var x=document.forms["myForm"]["email"].value;
var iframe = document.createElement("iframe");
var uniqueString = "asderwegthyuq123";
document.body.appendChild(iframe);
iframe.style.display = "none";
iframe.contentWindow.name = uniqueString;
var form = document.createElement("form");
form.target = uniqueString;
form.action = "http://www.secondwebsite.com";
form.method = "POST";
var input = document.createElement("input");
input.type = "hidden";
input.name = "email";
input.value = x;
form.appendChild(input);
document.body.appendChild(form);
form.submit();
return true;
}
</script>