자바 스크립트에 문제가 있습니다. 다중 선택 상자에서 옵션의 배경 이미지를 설정하려고합니다. Firefox 3.6.14에서는 작동하지만 Internet Explorer 8에서는 작동하지 않습니다. 문제점을 보여주기 위해 간단한 코드 샘플을 작성했습니다. 누구든지 내 문제에 대한 해결책을 가지고 있습니까?style.backgroundImage는 Firefox에서만 작동합니다.
<html>
<head>
<script language="javascript" type="text/javascript">
function changeIssueTypes(){
var testSelect = document.getElementById("testSelect");
var comboBoxTest = document.getElementById("comboBoxTest");
testSelect.options.length = 0;
if(comboBoxTest.value == 'optionTest1')
{
testSelect.options[0] = new Option();
testSelect.options[0].value = 'testOption1';
testSelect.options[0].innerHTML = 'Test option 1';
testSelect.options[0].style.backgroundImage = 'url(http://www.multimove.nl/images/icons/small/icon_document.gif)';
testSelect.options[0].style.backgroundRepeat = 'no-repeat';
}
if(comboBoxTest.value == 'optionTest2')
{
testSelect.options[0] = new Option();
testSelect.options[0].value = 'testOption1';
testSelect.options[0].innerHTML = 'Test option 1';
testSelect.options[0].style.backgroundImage = 'url(http://www.middelburg.nl/static/middelburgpresentation/images/icons/icon_pdf.gif)';
testSelect.options[0].style.backgroundRepeat = 'no-repeat';
}
}
</script>
</head>
<body>
<form>
<select id="comboBoxTest" onchange="changeIssueTypes()">
<option value="optionTest1" >Option test 1</option>
<option value="optionTest2" >Option test 2</option>
</select>
<br/>
<select multiple id="testSelect">
<option value="initialOption">Test initial option</option>
</select>
</form>
</body>
</html>
선택 상자 스타일로 악명 어렵습니다. 이것은 보통의 컨트롤을 사용하여 가능하지 않습니다. –