JS in general new open window very simple direct window.open (URL);
But because I want to pass parameters to the server, and the parameters look a long string, and the Get method has a limited length of commit parameters, I have the following requirements:
Implementing post Submissions in 1,js
2, the returned page is displayed in a new window
First of all, I did this:
$.ajax ({ "POST", ' ${contextpath}/analyse/detail.do ', data: {carnum:carnum,ids : Refids}, function(str_response) { var obj = window.open ("About:blank" ); Obj.document.write (Str_response); }
By jquery Ajax submission, the returned data is written in a new page, but because the browser will intercept the automatic pop-up window, which also requires users to unblock themselves, the user experience is poor,
Then I do this by simulating the submission of form forms.
functionPost (URL, PARAMS) {varTemp_form = document.createelement ("form"); Temp_form. Action=URL; Temp_form. Target= "_blank"; Temp_form. Method= "POST"; Temp_form. Style.display= "None"; for(varXinchPARAMS) { varopt = document.createelement ("textarea"); Opt.name=x; Opt.value=Params[x]; Temp_form. appendchild (opt); } document.body.appendChild (temp); Temp_form. Submit (); }
Note: If you want the target property of the new open window form to be set to ' _blank '
Then request post (' ${contextpath}/analyse/detail.do ', {carnum:carnum,ids:refids});
JS Post mode new open window