我需要将“cmd”隐藏文本设置为以下值。 Chrome 执行此脚本,但 Firefox(至少 3.6)不执行。
我检查了firefox中的java,还有“执行javascript”选项。我在 Firefox 中运行 jquery 的东西非常好。我该怎么办?
function envia() {
frm = document.forms['detalha'];
tx = frm.elements("cmd");
tx.value = '0';
alert('document pressed' + document.pressed);
if (document.pressed == '2') {
tx.value = '2';
} else if (document.pressed == '3') {
tx.value = '3';
} else if (document.pressed == '4') {
tx.value = '4';
}
return true;
}
<form name="detalha" action="/publicopj/Altera" onsubmit="envia()">
<input type="submit" value="Save" name="acao" onclick="document.pressed=3"/>
提前致谢。
最佳答案
document.forms[...].elements
是一个数组,而不是一个函数。您的 .elements 位上有 ()
,试图将其作为函数调用。
tx = frm.elements["cmd"]; // note the square brackets
关于javascript - 为什么这个 javascript 在 Chrome 中执行,但在 Firefox 中却不行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9295203/