Home > Web Front-end > JS Tutorial > Problems encountered in FireFox when using JS to submit parameters to create a form_javascript skills

Problems encountered in FireFox when using JS to submit parameters to create a form_javascript skills

WBOY
Release: 2016-05-16 17:43:26
Original
1058 people have browsed it

On a front-end page, parameters need to be submitted through JavaScript. Use JS to create a form and append the parameters to the form for submission. The code is as follows:
Js code:

Copy code The code is as follows:

functionloadConfig(gameUrl,skinId){
vartemp=document.createElement("form" );
temp.action="${createLink(controller:'mobileConfig',action:'beforeLaunchConfig')}";
temp.method="POST";
temp.style.visibility=" hidden";
varopt=document.createElement("input");
opt.name="gameUrl";
opt.id="gameUrl";
opt.value=gameUrl;
varopt2=document.createElement("input");
opt2.name="skinId";
opt2.id="skinId";
opt2.value=skinId;
temp.appendChild( opt);
temp.appendChild(opt2);
temp.submit();
}

This function can run successfully on Chrome and Safari, but when using FireFox (17.0.1) cannot be submitted successfully. After research, it is found that FireFox requires the page to have complete tag items when submitting the page form, that is,
. Therefore, small changes were made to this JS:
Js code:
Copy code The code is as follows:

functionloadConfig(gameUrl,skinId){
varpageDiv=document.getElementById("page");
vartemp=document.createElement("form");
temp.action="${createLink(controller:'mobileConfig',action:'beforeLaunchConfig')}";
temp.method="POST";
temp.style.visibility="hidden";
temp.name="loadConfigPage";
varopt=document.createElement("input");
opt.name="gameUrl";
opt.id="gameUrl";
opt. value=gameUrl;
varopt2=document.createElement("input");
opt2.name="skinId";
opt2.id="skinId";
opt2.value=skinId;
temp.appendChild(opt);
temp.appendChild(opt2);
pageDiv.appendChild(temp);
temp.submit();
}

Append the form created here in the tag, and then submit it successfully.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template