internet explorer-javascript在Chrome中有效,在IE中无效
internet explorer - javascript works in Chrome does not work in IE
在Chrome浏览器中,当您单击此网页上的CloudCover时,下面会显示一个描述。IE中没有显示描述。有什么建议可以在IE中使用吗?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>min test</title>
<script type='text/javascript'>
function showDescription (sel) {
var myVarDescip, myVarTEXT;
var myVar = (sel.value);
document.getElementById('putDescriptionHere').innerHTML = "";
myVarDescip = (myVar + "Descrip");
myVarTEXT = document.getElementById(myVarDescip).innerHTML;
document.getElementById('putDescriptionHere').innerHTML = myVarTEXT;
}
</script>
</head>
<body>
<select id="destSelect" size="3" multiple="multiple">
<option value="CloudCover" onclick="showDescription(this);">Cloud Cover</option>
</select>
<div id="CloudCoverDescrip" style="display: none">
<b>Cloud Cover:</b> The percentage of sky occluded by clouds.
</div>
<div id="putDescriptionHere"></div>
</body>
</html>
您不能在IE中的选项上附加鼠标事件,因此单击永远不会触发。
在select上使用onchange事件,而不是
<select id="destSelect" size="3" multiple="multiple" onchange="showDescription(this);">
FIDDLE
相关文章:
- 滚动在Chrome中有效,但在Firefox或IE中无效
- 为什么这个按钮在IE中有效,但在Firefox中无效
- 如何修复FF和IE中的Javascript无效日期错误
- 获取所选选项的Javascript在Webkit/FF中有效,但在IE中无效
- 使用空媒体查询调用matchMedia失败,IE中的参数无效
- 禁用字段在IE中有效,但在Firefox中无效
- Date对象在Chrome中有效,但在Safari、Firefox或IE中无效
- 带有谷歌地图和天气图像的网页只能在IE中运行,在Chrome中无效
- IE 中的调用对象无效错误
- window.open 在 IE 中抛出无效参数错误
- 在IE中收到错误,例如“参数数量错误或属性分配无效”
- 无效的调用对象 IE 11 长度的 XML 数组 (getElementsByTagName)
- 脚本 600:此操作的目标元素无效.(仅限 IE)
- 得到"无效日期“;当仅在Javascript中在IE 11中传递动态日期时
- 动画永远循环在Chrome中有效,但在IE中无效
- SCRIPT87:IE 9、ASP.NET C#中的参数无效
- table.cell[].innerText在IE中有效,但在mozilla中无效
- 为什么javascript函数在firefox中有效,而在Chrome或IE上无效
- "无效的参数"在IE 8上的jQuery.prepend()中
- IE 8无效的过程调用或参数