[英]IE8 Javascript Error
I have written a js method which runs perfectly on FF. 我写了一个在FF上完美运行的js方法。 This js method is called on the click of a radio button.
单击单选按钮将调用此js方法。
In IE, when I click the radio button, the js method is called only when I click somewhere on the form. 在IE中,当我单击单选按钮时,仅当我单击表单上的某个位置时才调用js方法。 I have no idea about this strange behavious in IE.
我不知道IE中这种奇怪的行为。
Any ideas? 有任何想法吗?
Thx 谢谢
Here is my code. 这是我的代码。
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
HTML CODE: HTML代码:
<h:selectOneRadio id="pid" value="#{Bean.pid}" onchange="javascript:checkPid();">
<f:selectItem itemLabel="label1" itemValue="value1"/>
<f:selectItem itemLabel="label2" itemValue="value2" />
<f:selectItem itemLabel="label3" itemValue="value3" />
</h:selectOneRadio>
JAVASCRIPT: JAVASCRIPT:
<script language="javascript" type="text/javascript">
function checkPid() {
//some basic js here
//even if I just give an one-liner alert stmt here, In IE it
//shows up only when I click somewhere on the form after I click
//on the radio button
}
Thanks in advance! 提前致谢!
Try the onclick event rather than the onchange event. 尝试onclick事件而不是onchange事件。
You'll need to modify your code though: 不过,您需要修改代码:
<h:selectOneRadio id="pid" value="#{Bean.pid}" onclick="checkPid(this);">
And your javascript function: 和你的JavaScript函数:
function checkPid(e) {
//do stuff with e.value
}
You should be able to validate what the user clicked on by e.value. 您应该能够通过e.value验证用户点击的内容。 This should work for both browsers.
这对两种浏览器均适用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.