ドキュメントをリロードした後、新しいウィンドウでドキュメントの準備ができているかどうかを確認するにはどうすればよいですか。
これが私の例です:
あるサイトから検索結果ページを新しいウィンドウに取得する必要があります (クロスドメインです)。最初に POST リクエストを作成する必要があります (おそらくセッションに検索パラメーターを保存します)。次に、reslut ページに移動します。
これが私のコードです:
var windowname = "window"+(new Date().getTime()); // so I can open multiple windows, not very relevant
var new_window = window.open("", windowname); // prepare named window
// prepare form with post data targeted to new window
var dataform = $("<form method='post' target='"+windowname+"' action='https://www.ebi.ac.uk/chembldb/compound/smiles/'><input name='smiles' value='"+$("#id_smiles").text()+"'></form>");
// Need to get the form into page for Mozilla, webkit allows to submit forms that are not in page
$("body").append(dataform);
// submit the form and remove it, no need to keep it
dataform.submit().remove();
// form opens in my new window
$(new_window.document).ready(function(){
// this is carried out apparently too soon, because the POST data didn't work
// when I use timeout (commented below, but i don't like this solution) it works
window.open("https://www.ebi.ac.uk/chembldb/index.php/compound/results/1/chemblid/asc/tab/smiles", windowname);
// setTimeout( function(){window.open("https://www.ebi.ac.uk/chembldb/index.php/compound/results/1/chemblid/asc/tab/smiles", windowname)}, 1000);
});
そのサイトでは、最初に AJAX を使用して POST リクエストを作成し、次に単純に作成しますが、クロスドメインであるため、私には不可能です。