JavaScript在Internet Explorer 9中不工作

JavaScript在Internet Explorer 9中不工作,javascript,jsp,Javascript,Jsp,正在尝试在选择选项上显示图像预览。以下代码在Firefox中运行良好,但在Internet Explorer中运行不正常 我试着设置一个警报来显示图像的scr,它在Firefox中显示正确的路径,但在IE中它显示的是garbeg值,而不是1.jpg,它显示的是%01.jpg 你知道如何在IE上运行吗 newAray包含图像名称,如1.jpg、2.jpg 代码如下: <form id = " delete_image" action="DeleteImages.jsp" metho

正在尝试在选择选项上显示图像预览。以下代码在Firefox中运行良好,但在Internet Explorer中运行不正常

我试着设置一个警报来显示图像的scr,它在Firefox中显示正确的路径,但在IE中它显示的是garbeg值,而不是1.jpg,它显示的是%01.jpg

你知道如何在IE上运行吗

newAray包含图像名称,如1.jpg、2.jpg

代码如下:

   <form  id = " delete_image" action="DeleteImages.jsp" method="post" >
<select  id = "image_id_delete"  name= "image_id_delete"  onchange="CngColor(this);" style="color:#4B616A; background-color:#eaeced; border:1px solid #939fa4; height:26px; width:120px; padding-bottom: 4px; text-align:center;">
<option value=""><---Select---></option>
<%

for(int i=0;i<newAray.size();i++) 
{ %> 


<option > <%= newAray.get(i) %></option>
<% 
}

%>
</select>


&nbsp; &nbsp; &nbsp;
<img id="Img1" src="images/1.jpg" width=100 height=100 >

<input type="submit" value= "Delete" style="color:#ffffff; background-color:#939fa4; border:1px solid #4b616a; font-weight: bold; height: 27px; padding-bottom: 3px; cursor: pointer;" >


</form>
谢谢大家的回复。 我得到了答案:

function CngColor(obj){
index=obj.selectedIndex;

document.getElementById('Img1').src= 'images/'+obj.options[index].text;
//cahnged value to text
}

属性
“value”
在某些版本的Internet Explorer中不起作用,因此请从选项对象的
“text”
字段中读取值。

我认为jsp是java的一部分:)它在IE中究竟是如何失败的?这个“Img1”元素是什么?它没有出现在您发布的代码中。IE开发者控制台中是否有错误?是的,但是由于java有许多其他部分,网站引入了jsp标记!!JavaScript在HTML生成的DOM上运行。显示HTML,而不是生成它的JSP。控制台上没有错误。。
function CngColor(obj){
index=obj.selectedIndex;

document.getElementById('Img1').src= 'images/'+obj.options[index].text;
//cahnged value to text
}