This function is implemented in pure JS on the network. This document describes how to use jquery to implement this function. If you need it, you can refer to the function that already exists on the network, is implemented in pure JS. However, the project found that this function is not compatible with Firefox, so I have rewritten this method.
The 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 ';
The 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 = $ ("",{
'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 ($ ("", {'Type': 'ddn', '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.