This function is already available on the network and is implemented in pure JS. However, the project found that this function is not compatible with Firefox, so I have rewritten this method.
Copy codeThe Code is as follows:
// New window configuration by default
Var windowDefaultConfig = new Object;
WindowDefaultConfig ['directory'] = 'no ';
WindowDefaultConfig ['location'] = 'no ';
WindowDefaultConfig ['menubar '] = 'no ';
WindowDefaultConfig ['resizable'] = 'yes ';
WindowDefaultConfig ['rollbars'] = 'yes ';
WindowDefaultConfig ['status'] = 'no ';
WindowDefaultConfig ['toolbar '] = 'no ';
Copy codeThe Code is as follows:
/**
* JQUERY implementation for opening a new window in the form of POST
@ Param: url to be opened
@ Param: args URL parameter. The data type is object.
@ Param: name refers to the name of the URL window to be opened. If the same button needs to be opened repeatedly,
Instead of refreshing the window opened for the first time, this parameter should be different each time
@ Param: windowParam parameter configuration for the newly opened window
* @ Author: haijiang.mo
*/
Function jQueryOpenPostWindow (url, args, name, windowParam ){
// Create a form object
Var _ form =$ ("<form> </form> ",{
'Id': 'template ',
'Method': 'post ',
'Action': url,
'Target': name,
'Style': 'display: none'
}). AppendTo ($ ("body "));
// Add hidden fields to the form
For (var I in args ){
_ Form. append ($ ("<input>", {'type': 'den den ', 'name': I, 'value': args [I]});
}
// Clone window parameter object
Var windowConfig = clone (windowDefaultConfig );
// Configuration window
For (var I in windowParam ){
WindowConfig [I] = windowParam [I];
}
// Window configuration string
Var windowConfigStr = "";
For (var I in windowConfig ){
WindowConfigStr + = I + "=" + windowConfig [I] + ",";
}
// Bind the submitted trigger event
_ Form. bind ('submit ', function (){
Window. open ("about: blank", name, windowConfigStr );
});
// Trigger the submission event
_ Form. trigger ("submit ");
// Delete a form
_ Form. remove ();
}
Record it and you can use it later.