简体   繁体   中英

From javascript, how do I get access to the response page of a submit

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 access 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM