Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 17:43:26986browse

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.
Statement:
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