为什么我单击此按钮时会将此错误消息发送到FireBug控制台?

时间:2015-04-13 09:38:03

标签: javascript jquery html javascript-events xhtml

我绝对是JavaScript的新手,我在使用它的页面中遇到以下问题。

所以我有一个页面,我有这个按钮:

<div class="bottoneDiv">

                <input class="bottone" type="text" readonly
                       value="Invia" onclick='Javascript: loadingPopUp(); return InviaEmail()'
                       onMouseOver="'Invia';return true"/>

                <input class="bottone" type="text" readonly
                       value="Indietro" onclick='Javascript: loadingPopUp(); return AnnullaEmail()'
                       onMouseOver="'Indietro';return true"/>
</div>

正如您在此输入按钮上看到的,我已经定义了 onclick 事件,因此当用户单击按钮时,会执行 loadingPopUp()功能,只需加载加载弹出窗口,直到加载href页面(它完全适用于其他页面)。

问题是,在此页面中,当我点击FireBug控制台中的 Indietro 按钮时,出现此错误消息:

ReferenceError: Calendario is not defined
    VALORE_SOCIETA = 'CLIENTE PROVA';Calendario();

我无法理解为什么当我点击此按钮时会尝试执行此 Calendario()功能(在我看来,它不会被调用到我的的代码中loadingPopUp()功能就是:

 function loadingPopUp() {

        var blurDiv = document.createElement("myPage");
        blurDiv.id = "blurDiv";
        blurDiv.style.cssText = "position:absolute; top:0; right:0; width:" + screen.width + "px; height:" + screen.height + "px; background-color: ci; opacity:0.5; filter:alpha(opacity=10)";

        try {
            // alert(navigator.appName);
            var is_ie = (navigator.appName == "Microsoft Internet Explorer");
            // alert(is_ie);

            if (is_ie) {
                top.window.workspace.document.appendChild(blurDiv);
            }
            // top.window.workspace.document.appendChild(blurDiv);

            top.window.workspace.document.getElementById('light').style.display = 'block';

        } catch (e) {
        }
        // document.getElementById('fade').style.display = 'block';

    }

和另一个调用函数简单地将redirext用于特定的URL:

function AnnullaEmail() {
    document.location.href = "edi.do?serv=4.0"
}

因此,使用FireBug JavaScript调试器,我可以看到,当我点击 Indietro 按钮时,首先执行之前的 loadingPopUp()功能,在我看来,执行此行会抛出异常:

top.window.workspace.document.getElementById('light').style.display = 'block'; 

并在FireBug控制台中显示错误消息:

ReferenceError: Calendario is not defined
    VALORE_SOCIETA = 'CLIENTE PROVA';Calendario();

所以我在这个页面中搜索这个字符串,然后我发现了它:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td width="100%" align="RIGHT" valign="BOTTOM">
            <font size="-2" face="arial, helvetica">
                <script language="JavaScript">
                    VALORE_SOCIETA ='<%=request.getSession().getAttribute("USER")==null?"":((User)request.getSession().getAttribute("USER")).getRagioneSociale()%>';
                                Calendario();
                </script>
            </font>
        </td>
    </tr>
</table>

此表中的此脚本会话似乎是当我点击 Indietro 按钮时显示在FireBug控制台中的错误的原因,因为此消息是从它生成的,但是:

  1. 为什么我点击 Indietro 按钮获取此错误,如果它没有调用这段代码?

  2. 这段代码有什么问题?为什么会生成此错误消息?我该如何解决?

  3. TNX

0 个答案:

没有答案