From javascript I know how to: open an html page in another window, fill a form on the other window submit the form from the other window
What I don't know is, how do I then access the response page from the submit. Is it possible from javascript?
This is as far as I've gotten:
var nwin=open("http://myotherpage.html","");
var frm_p = nwin.document.getElementById("frm_id");
var data_p = nwin.document.getElementById("input_data_id");
data_p.value = "my data";
frm_p.submit();
To make things clearer, myotherpage.html has a form:
<form id="frm_id" action="getResponse.html" method="post">
<input id="input_data_id" type="text" />
<input type="submit" value="Submit" />
</form>
I want to get acce开发者_高级运维ss to the getResponse.html page that comes back from the submit
Make sure the form's action='#'
, then put en event listener on frm_p
. You should be able to access the form's elements in the listener, and then close the window after you get the value of all of them.
If clicking submit closes the open window, and you then no longer have access to the form's elements, I would change the submit button to type button
and put the event listener on the button. Just make sure you close the window manually in the listener.
精彩评论