Use the jquery implementation to post to open a new window _jquery

Source: Internet
Author: User
The function on the network already has this function, is realizes with the pure JS. However, it was found in the project that this function was not compatible with Firefox, and I rewrote this method.
Copy Code code as follows:

Default New Window Configuration
var windowdefaultconfig = new Object;
windowdefaultconfig[' directories ' = ' no ';
windowdefaultconfig[' location ' = ' no ';
windowdefaultconfig[' menubar ' = ' no ';
windowdefaultconfig[' resizable '] = ' yes ';
windowdefaultconfig[' scrollbars '] = ' yes ';
windowdefaultconfig[' status ' = ' no ';
windowdefaultconfig[' toolbar ' = ' no ';

Copy Code code as follows:

/**
* jquery implementation to open a new window as a post form
@param: URL needs to open URL
@param: args url parameter, data type Object
@param: Name opens the name of the URL window, and if the same button needs to open the new window repeatedly,
Instead of refreshing in the first open window, this parameter should be different each time
@param: Windowparam parameter configuration for new open windows
* @author: Haijiang.mo
*/
function Jqueryopenpostwindow (url,args,name,windowparam) {


Create a Form Object
var _form = $ ("<form></form>", {
' ID ': ' tempform ',
' 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 ': ' Hidden ', ' name ': I, ' value ': Args[i]}));
}

Cloning a 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]+ ",";
}

Binding Commit Trigger Event
_form.bind (' Submit ', function () {
window.open ("About:blank", name,windowconfigstr);
});

Trigger Commit Event
_form.trigger ("submit");
Form deletion
_form.remove ();
}

Write it down and you can use it later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.