【问题标题】:latest version of firefox and chrome issue with javascript最新版本的 Firefox 和 chrome 问题与 javascript
【发布时间】:2018-10-15 14:41:42
【问题描述】:
onclick="javascript:selectAllCheckBox(this,document.thisJSP.chkUser);"

在这里,最新版本的 firefox 和 chrome 显示以下错误消息:-

TypeError: document.thisJSP is undefined

.thisJSP 是我的表单名称...

提前谢谢。

这是我的表格

<form action="AjaxRightsMenu.jsp" name="thisJSP" method="POST">
  <FieldSet>
    <Legend vAlign="Top">
      <Font color="green">User Details </Font>
    </Legend>
    <div vAlign="Top" style="overflow: scroll; height: 280px; max-height: 280px">
      <input type="hidden" name="hdnScrollValue" value="<%=myController.scrollValue%>">
      <Table Align="left" border="1" cellpadding="0" cellspacing="1" vAlign="Top" Width="100%">
        <Thead>
          <tr>
            <th width="9%" class="unsortable">
              <B><input type="button" name="chkSelectAll" value="Check All" onclick="javascript:selectAllCheckBox(this,document.thisJSP.chkUser);"></B>
            </th>
            <th align="left" Width="10%" colspan="1">Group Name</th>
            <th align="left" Width="10%" colspan="1">Loc Name</th>
            <th align="left" Width="10%" colspan="1">APP Name</th>
            <th align="left" Width="10%" colspan="1">Menu Name</th>
            <th align="left" Width="10%" colspan="1">View Rights</th>
            <th align="left" Width="10%" colspan="1">Add Rights</th>
            <th align="left" Width="10%" colspan="1">Edit Rights</th>
            <th align="left" Width="10%" colspan="1">Del Rights</th>
            <th align="left" Width="10%" colspan="1">Auth Rights</th>
          </tr>
        </Thead>

【问题讨论】:

  • 请提供完整的代码,以便我们重现您的问题。
  • DOM 元素是否应该可以直接从文档中通过名称访问?你不应该使用document.getElementsByName 来获取元素吗?
  • @HiddenHobbes 请找到下面的 javascript 和调用此 onclick 事件的输入标记...!!!
  • 把你的代码放在这里,特别是你定义你的表单类或对象的地方。也许是因为新的 JavaScript 类定义。
  • 仅供参考,您不需要将javascript: 放在onclick 属性的开头。仅当您将 JS 放入 URL 时才需要这样做。

标签: javascript html forms html-table event-handling


【解决方案1】:

AFAK,你的代码太丑了!

以下是一些建议:

  1. 通过定义一个新函数来分离你的 ui 定义和它的逻辑;
  2. 使用 document.getElementById() 函数访问 DOM 元素,而不是按名称;
  3. 你应该试试 jQuery。

【讨论】:

  • 感谢您的建议,但如果您可以提供可以与我的代码相关的示例,那将不胜感激,因为 m 与 jQuery 没有更多联系。
【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 2015-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-03
  • 2011-10-24
相关资源
最近更新 更多