【问题标题】:Got an exception of TypeError: window.parent.leftframe.document.viewForm is not a function遇到 TypeError 异常:window.parent.leftframe.document.viewForm is not a function
【发布时间】:2019-07-05 08:13:39
【问题描述】:

这个 JS 在 IE 上运行,但是当我使用 Chrome 时,总是出现这个错误:

异常 : TypeError: window.parent.leftframe.document.viewForm is not a function at Checked

我使用此代码检查表单输入,如果用户在该表单中输入命令,则返回 true)

你能解释一下吗?

谢谢! 文斯

function Checked() 
    {
    if (window.parent.leftframe.document.viewForm.changed.value == "true") {
        return true;
    }
    else {
        for (k = 0; k < 30; k++) {
            memcom = "member[" + i + "].command";    
            if (window.parent.leftframe.document.viewForm(memcom) != null && window.parent.leftframe.document.viewForm(memcom).value != "") {
        return true;
        }
    }
    return false;
    }
}

viewFrom 在这个 JSP 中:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<table class="Product" cellspacing="1">
    <html:form action="/viewSubmit" method="post" onsubmit="return onSubmitForm()">
        <input type="hidden" name="submited" value="false"> 
        <html:hidden property="action"></html:hidden>
        <html:hidden property="changed"></html:hidden>
......

                <logic:equal name="viewForm" property="opt.withMemberList" value="true">
.......

                        <td colspan="3" class="Product2">
                <a href="#" onclick="return <bean:write name="viewForm" property="listpURL" listp="false"/>"><IMG src="images/product_list_button.gif" border="0" /></a>                
            </td>
..........              <tr>
                        <logic:iterate id="member" name="viewForm" property="members" indexId="i">
                ....                
                <html:hidden indexed="true" name="member" property="remark"></html:hidden>                                  
                <td align="location" class="Product2">
                    <html:select name="member" indexed="true" property="command" disabled="false">
                    <html:options name="member"  property="commandSelection"/>                                              
                    </html:select>          
                </td>
                         </tr>
......
        </logic:equal>
    </html:form>
</table>        

</html>

Chrome 开发工具输出:

我可以在 window.parent.leftframe.document.viewForm 中看到这个

name:"member[0].command"
nextElementSibling:null
nextSibling:text
nodeName:"SELECT"
nodeType:1
nodeValue:null
nonce:""

当鼠标移到该名称时,我看到 [31].name,与其他名称相同。 如何从中获取 nodeValue ?

谢谢!

【问题讨论】:

    标签: javascript function google-chrome typeerror


    【解决方案1】:

    说 IE 没有给您错误(您应该得到)可能更正确。

    在第一个if 语句中,window...viewForm... 被视为具有名为“已更改”的属性的对象,该对象具有名为“值”的属性;但是,稍后您将相同的东西引用为函数。查看 Chrome 中的 document 属性/对象,我没有看到 viewForm 属性(因此,Chrome 中的错误)。

    此外,如果您将来发布正在使用的 HTML 位,这将非常有帮助。

    【讨论】:

    • 我也添加了 ViewForm 代码。这在IE上运行了很长时间,但是我们在Chrome上解决了这个问题,不确定这是否与AcionForm有关。
    • 1) 看起来 ViewForm 代码是 java,而不是 javascript。 2) window.parent.leftframe.document.viewForm 定义是什么?
    • 在调查了这个别人写的项目后,我发现viewForm在那个使用Strtuts 1的JSP中。我也更新了viewForm代码。
    • 不要使用.name,而是使用.value(在javascript中)。我认为 .getParameter("command") 可以在 JSP 中工作 - 但这开始超出我的领域。
    • 谢谢大家,.getParameter 不起作用。我使用了 .value,它起作用了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    • 1970-01-01
    • 2021-01-21
    • 2021-10-01
    • 2018-11-16
    相关资源
    最近更新 更多