簡體   English   中英

從 javascript,我如何訪問提交的響應頁面

[英]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

我不知道的是,我如何從提交訪問響應頁面。 是否可以從 javascript 開始?

這是據我所知:

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();

為了讓事情更清楚,myotherpage.html 有一個表格:

<form id="frm_id" action="getResponse.html" method="post">
<input id="input_data_id" type="text" />
<input type="submit" value="Submit" />
</form>

我想訪問從提交返回的 getResponse.html 頁面

確保表單的action='#' ,然后將 en 事件偵聽器放在frm_p上。 您應該能夠在偵聽器中訪問表單的元素,然后在獲得所有元素的值后關閉 window。

如果單擊提交會關閉打開的 window,然后您將無法再訪問表單的元素,我會將提交按鈕更改為鍵入button並將事件偵聽器放在按鈕上。 只需確保在偵聽器中手動關閉 window 即可。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM