Firefox中php制作的Javascript链接

Firefox中php制作的Javascript链接,php,javascript,firefox,Php,Javascript,Firefox,我正在编写一个脚本,它在IE和Chrome中运行良好,但在Firefox中链接不起作用 基本上,我使用php查询数据库并在页面内生成一些链接 相关链接代码的示例: <TD class="bodycopyblue" onmouseover="this.style.background='#FFFF80';this.style.cursor='pointer'" onmouseout="this.style.background='#FFFFFF'" onclick="

我正在编写一个脚本,它在IE和Chrome中运行良好,但在Firefox中链接不起作用

基本上,我使用php查询数据库并在页面内生成一些链接

相关链接代码的示例:

<TD class="bodycopyblue"
    onmouseover="this.style.background='#FFFF80';this.style.cursor='pointer'"
    onmouseout="this.style.background='#FFFFFF'"
    onclick="getAccountDetails(<?php print $accountinfo['audio_account_id']; ?>)"
>view CDRs</TD>
正在提交一份表格:

<FORM id="accountform"
    action="accountdetails.php?month=<?php print $cdate['mon']; ?>&year=<?php print $cdate['year']; ?>"
    method="post">
<INPUT id="aid" name="aid" type="hidden" value=0>
</FORM>

生成的HTML是什么?在Firefox中进行“查看源代码”并将代码粘贴到问题中。您很可能会看到格式错误的HTML

试试看

function getAccountDetails(account_id) {

        document.getElementById('aid').value=account_id;
        accountform.submit();
}

Firebug 1.4和FF 3.5的工作有点棘手,您需要打开Firebug的控制台(F12,或单击右下角的Firebug图标),然后在控制台打开的情况下重新加载页面。一旦Firebug窗口打开,单击“控制台”选项卡,可能会显示错误

我唯一的另一个建议是在JS语句之后添加一个semilcolon

onclick="getAccountDetails(<?php print $accountinfo['audio_account_id']; ?>);"
onclick=“getAccountDetails();”
Firefox通常非常宽容——奇怪的是它在其他浏览器中工作,而不是FF。作为最后一个测试,去掉mouseover和mouseout事件,只需离开onclick,看看它是否能够自行工作

function getAccountDetails(account_id) {
    accountform.aid.value=account_id;
    accountform.submit();
}
什么是
accountform
?如果您没有在任何地方执行
var accountform=…
操作,您将不会得到任何具有该名称的变量,除了在IE中错误地为
窗口
范围中的命名项创建变量之外

不要依赖于此,请明确设置
accountform

function getAccountDetails(account_id) {
    var accountform= document.getElementById('accountform');
    accountform.elements.aid.value=account_id;
    accountform.submit();
}

accountform是我试图提交的表单的id。然后您必须使用
document.getElementById
将其放入变量中。感谢firebug提供的信息,它确实显示了java脚本错误。“accountform未定义”。显然,它不喜欢我在函数中引用元素的方式。虽然我必须为帐户执行document.getElementById,并从该结果调用submit,但这确实有效。
function getAccountDetails(account_id) {
    var accountform= document.getElementById('accountform');
    accountform.elements.aid.value=account_id;
    accountform.submit();
}