我的一项职能是,当用户选择一个或多个项目时,将这些项目移至清单箱顶(选定的提炼)和滚动到顶,以便其重新可见。 它在我测试的所有主要浏览器工作。 当我拥有这一职能时,问题就出现在一个桌子内。 当我这样做并使用国际电子数据8时,它就进行分类和复制;适当强调,但只是向顶点倾斜。 Java本通过基本的JALint检查,网页通过超文本验证。 我是否找到了IE8的qui子? 我把这个名单箱式和样子放在一起;滚动功能错失了吗?
<script type="text/javascript">
function Arrange(obj) {
var countSel = 0, countNSel = 0, i, arr_selected = [], arr_unselected = [];
for (i = 0; i <= obj.length - 1; i++) {
if (obj.options[i].selected) {
//create array with all selected items then sort it
arr_selected[countSel] = [];
arr_selected[countSel][0] = obj.options[i].text;
arr_selected[countSel][1] = obj.options[i].value;
countSel = countSel + 1;
arr_selected.sort();
}
else {
//create array with all UNselected items then sort it
arr_unselected[countNSel] = [];
arr_unselected[countNSel][0] = obj.options[i].text;
arr_unselected[countNSel][1] = obj.options[i].value;
countNSel = countNSel + 1;
arr_unselected.sort();
}
}
if (countSel !== 0) {
//overwrite listbox options with selected items
for (i = 0; i <= countSel - 1; i++) {
obj.options[i] = new Option(arr_selected[i][0], arr_selected[i][1]);
}
//overwrite listbox options with UNselected items
for (i = 0; i <= countNSel - 1; i++) {
obj.options[countSel] = new Option(arr_unselected[i][0], arr_unselected[i][1]);
countSel = countSel + 1;
}
}
//for showing selected items
//scroll to the top of the list and select the appropriate items
//it s in reverse order because IE8 wanted to only scroll to the last item selected
obj.selectedIndex = 0;
for (i = arr_selected.length - 1; i >= 0; i--) {
obj.options[i].selected = true;
}
}
</script>
</head>
<body>
<form name="frm" action="post">
<table><tr><td>test:</td><td>
<select size="4" name="cbostaffcontact" multiple onblur="Arrange(document.forms[0].cbostaffcontact);">
<option value="user1">Al</option>
<option value="user2">Bob</option>
<option value="user3">Christy</option>
<option value="user4">Jane</option>
<option value="user5">Randy</option>
<option value="user6">Tom</option>
<option value="user7">Zed</option>
</select>
</td></tr></table>
</form>