【问题标题】:javascript doesn't work all the time in IEjavascript 在 IE 中并非一直有效
【发布时间】:2013-08-29 12:26:16
【问题描述】:

在jsp中使用spring表单标签

以下是我的脚本,我将其用于分页:

function getNextPage(){
var next = document.getElementById('nextPageID');
next.checked=true;
var buttonName = document.getElementById('refreshbuttonID');
buttonName.click();
}

当用户在视图中单击Next(使用jsp)时,onclick 事件我正在调用getNextPage();

<button type="submit" onclick="getNextPage();">Next</button>

我将隐藏复选框设置为 true

<td>
     <form:checkbox id="nextPageID" path="nextPage"/>  
     <input type="hidden" value="1" name="_nextPage"/>
</td>

然后调用控制器中的方法来获取下一个结果并显示在页面上。

在 chrome 和 firefox 中一切正常,当涉及 IE 时,有时会,有时不会。并且页面不断刷新旧数据..它一直在调试模式下工作(即使在 IE 中)

It is not hitting the javascript in IE on some occassions。我在功能上缺少什么或在 IE 中有什么不同的事情要做吗?有什么建议!

【问题讨论】:

  • 这真的是你的全部代码吗?另外我认为需要进行一些调试。
  • 我还能在这里展示什么?
  • 它没有在 IE 中的 onclick 事件中点击 javascript
  • 你能举个例子吗?
  • &lt;form:checkbox /&gt; 到底是什么?

标签: javascript spring jsp


【解决方案1】:

我将根据给出的有限信息进行猜测:将您的按钮更改为使用type="button"

<button type="button" onclick="getNextPage();">Next</button>

...因为如果您在表单中有一个提交按钮并且您没有取消默认行为(您的代码没有),它将尝试提交表单以及您的代码正在执行的操作。

【讨论】:

    猜你喜欢
    • 2013-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    • 2018-03-12
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    相关资源
    最近更新 更多