The problem comes from the features and restrictions of get and post. For GET requests, we can easily use window. opener communicates with the parent page. However, according to the HTTP protocol, the maximum URL length is 2083 bytes, and the length of data transmitted by get is 2048 bytes. For post requests, although there is no limit on the maximum length, it is not convenient to use window. opener to communicate with the parent page.
There are many ways to use JavaScript to automatically convert a GET request into a POST request. The main idea is to dynamically construct an IFRAME, then, assign the URL parameter value in the GET request to the input control, set the form action address, and call the submit method.
Someone in the garden has given a solution, http://www.cnblogs.com/ppchen/archive/2008/03/18/1109607.html
The record is as follows: Code
VaR Postnewwin = Function (URL ){
VaR Urlarr = URL. Split ( " ? " );
VaR Posturl = Urlarr [ 0 ];
VaR Postdata = Urlarr [ 1 ];
VaR IFRAME = Document. getelementbyid ( " Postdata_iframe " );
If ( ! IFRAME ){
IFRAME = Document. createelement ( " IFRAME " );
IFRAME. ID = " Postdata_iframe " ;
IFRAME. scr = " About: blank " ;
IFRAME. frameborder = " 0 " ;
IFRAME. style. Width = " 0px " ;
IFRAME. style. Height = " 0px " ;
VaR Form = Document. createelement ( " Form " );
Form. ID = " Postdata_form " ;
Form. Method = " Post " ;
Form.tar get = " _ Blank " ;
Document. Body. appendchild (IFRAME );
Iframe.content+doc ument. Write ( " <Body> " + Form. outerhtml + " </Body> " );
}
Iframe.contentdomaindoc ument. getelementbyid ( " Postdata_form " ). Innerhtml = " <Input name = 'postdata' id = 'postdata' type = 'text' value =' " + Postdata + " '/> " ;
Iframe.contentdomaindoc ument. getelementbyid ( " Postdata_form " ). Action = Posturl;
Iframe.contentdomaindoc ument. getelementbyid ( " Postdata_form " ). Submit ();
};
For example, a function is used to open a new page with a GET request.
Function opennewwindow ()
{
VaR url = http://www.website.com/page1.aspx? P1 = V1 & p2 = V2;
VaR win = Window. Open (URL );
}
Because of the length of Ur, we can use post to submit the request as follows:
Function opennewwindow ()
{
VaR url = http://www.website.com/page1.aspx? P1 = V1 & p2 = V2;
// Var win = Window. Open (URL );
Postnewwin (URL );
}
One problem here is that after using this method, you cannot use window. opener to interact with the parent page, because through this function, the GET request has been changed to a POST request. In order to use the post method to increase big data, you can also use window. open (URL) window. opener communicates with the parent page. Here we will make a small revision. First, we will use window. when you open (URL), add a parameter to specify the name of the window to open, as shown below:
Function opennewwindow ()
{
VaR url = http://www.website.com/page1.aspx? P1 = V1 & p2 = V2;
VaR winname = "";
VaR win = Window. Open ("about: blank", winname );
Postnewwin (URL, winname );
}
Modify the postnewwin function, pass the handle of the new window to the function, and set the target of the POST request to this parameter, as shown below:
VaR Postnewwin = Function (URL, winname ){
.........
Form.tar get = Winname ;
.......
};
In this way, you can use both post and get methods.
========================================================== ======================
More powerful form functions than Sharepoint, graphical process design, perfect combination with Asp.net, support for vs.net programming Extension
========================================================== ======================