Androidアプリケーションで使用されるHTMLページがあります。このページからサーバーにデータを投稿する必要があり、応答はダウンロードする必要のある添付ファイルです。この目的のために、隠しiframeハックを使用しました。しかし、残念ながらその失敗。誰かが根本的な原因を説明できますか?
関数download(){ var iframe = document.createElement( "iframe"); //iframe.src = "http:// localhost:9080 / HttpOptions / MultiPartServlet"; iframe.style.display = "none"; iframe.id = "myframe"; document.body.appendChild(iframe); var doc = document.getElementById( "myframe")。contentWindow.document; var form = doc.createElement( "form"); form.setAttribute( "name"、 "theForm"); //フォームに名前を付けます form.setAttribute( "id"、 "theForm"); //フォームに名前を付けます form.setAttribute( "action"、 "http:// localhost:9080 / HttpOptions / MultiPartServlet"); //フォームにアクションを与える form.setAttribute( "method"、 "post"); //フォームにメソッドを与える var par1 = doc.createElement( "input"); par1.setAttribute( "name"、 "theSubmit"); //入力に名前を付けます par1.setAttribute( "type"、 "submit"); //送信ボタンにします par1.setAttribute( "value"、 "Submit"); //入力に値を与える var par2 = doc.createElement( "input"); par2.setAttribute( "name"、 "name"); //入力に名前を付けます par2.setAttribute( "type"、 "text"); //送信ボタンにします par2.setAttribute( "value"、 "deepak"); //入力に値を与える form.appendChild(par1); form.appendChild(par2); doc.body.appendChild(form); var myframe = document.getElementById('myframe'); var innerDoc = iframe.contentDocument || iframe.contentWindow.document; form.submit(); }