- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试制作一个为 IE8 开发的简单 java 脚本页面,与 IE9 及更高版本兼容。当我尝试使用原型(prototype)的 getValue() 方法时,选择标签给出“TypeError:对象不支持属性或方法'getValue'”。此页面在所有版本的 IE 中都可以正常工作,除了 IE9 中少数没有管理员权限的县用户。
有人可以帮我解决这个问题吗?
<!DOCTYPE html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="prototype.js"></SCRIPT>
</head>
<body style="width:500px">
<form id="example" action="#" onsubmit="return false">
<div id="container">
<select size="7" style="width:auto;" name="commonRTSelect" id="commonRTSelect" multiple>
<option value="volvo" selected>Volvo</option>
<option value="saab" selected>Saab</option>
<option value="mercedes" selected>Mercedes</option>
<option value="audi">Audi</option>
</select>
<input type="text" style="width:auto;" name="fname" id="fname" value="madhu">
<br>
</div>
</form>
<input type="button" value="Toggle" onclick="showResult();"/>
<script>
function showResult() {
var elems = $('container').select('input','select','textarea');
elems.each( function(e){
if(e instanceof HTMLElement) {
alert("Yes.."+e.name+" is an instance of HTMLElement");
}
else {
alert("No "+e.name+" is not an instance of HTMLElement. it is " + e);
}
});
try{
alert("Dropdown Value>> " + $('commonRTSelect').getValue());
}
catch(e) {
alert(e);
}
}
</script>
</body>
</html>
当我调试这个问题时,我发现select标签的类型是DispHTMLWndSelectElement。无法在此处附加屏幕截图..
最佳答案
而不是,
$('commonRTSelect').getValue()
...请尝试,
$F('commonRTSelect')
在内部,它们应该调用相同的函数,实际上是 checking the element's tag name 。这里的问题是 DispHTMLWndSelectElement
没有从 HTMLSelectElement
继承 getValue()
函数,因此解决方案是不调用实例方法。
至于 IE 为何再次决定破坏兼容性,大家都在猜测。也许它检测到一个不在文档字符集中的字符并回退到另一种渲染模式。如果不比较页面源和 ouigii 板,就很难判断。
关于javascript - 为什么在 IE9 中 Select Element 的类型是 DispHTMLWndSelectElement 而不是 HTMLSelectElement?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25269557/
我正在尝试制作一个为 IE8 开发的简单 java 脚本页面,与 IE9 及更高版本兼容。当我尝试使用原型(prototype)的 getValue() 方法时,选择标签给出“TypeError:对象
我是一名优秀的程序员,十分优秀!