Use JS to create a form in Firefox can not submit the problem

Source: Internet
Author: User
On a front-end page, you need to submit parameters via JavaScript, use JS to create form forms, and append the parameters into the form to submit the code as follows: JS Code: Function loadconfig (Gameurl,skinid) {                    var temp = document.createelement ("form");                     temp.action =  "${createlink (Controller: ' Mobileconfig ',  action: ' Beforelaunchconfig ')}";                             temp.method =  "POST";                    temp.style.visibility= "Hidden";                    var  opt = document.createelement ("input");                    opt.name =  "Gameurl";                    opt.id =  "Gameurl";                    opt.value =  gameurl;                    var opt2 = document.createelement ("input");                    opt2.name =  "SkinId";                   opt2.id =   "SkinId";                    opt2.value = skinId;                &nBsp;   temp.appendchild (opt);                    temp.appendchild (OPT2);                    temp.submit ();                }  

The feature was successfully run on both Chrome and Safari, but was not successfully submitted when using Firefox (17.0.1), and after research found that Firefox submitted a page form when it required a complete label for the page, that is JS Code: Function loadconfig (Gameurl,skinid) {                    var pagediv = document.getelementbyid ("page");                    var  temp = document.createelement ("form");                    temp.action =  "${createlink (Controller: ' Mobileconfig ',  action: ' Beforelaunchconfig ')} ";                             temp.method =  "POST";                    temp.style.visibility= "hidden";                    temp.name =  "Loadconfigpage";                    var opt =  Document.createelement ("input");                    opt.name =  "Gameurl";                    opt.id =  "Gameurl";                    opt.value =  gameUrl;                    var opt2 = document.createelement ("input");                    opt2.name =  "SkinId";         &NBsp;          opt2.id =  "SkinId";                    opt2.value =  skinId;                    temp.appendchild (opt);                    temp.appendchild (OPT2);                    pagediv.appendchild (temp);                    temp.submit ();               }  

  Append the form form created here in <body> tags, and then commits it successfully. Reference blog: http://bytes.com/topic/javascript/answers/542837-document-getelementbyid-myform-submit-does-not-work

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.