请帮我看一下这个代码,它读取图片是没有问题的但是,循环显示出来的时候却有问题“显示的图片数量是对的,但是却是重复的”就是说本来有4个图片但是它显示的时候能看到的只有2个,这两个图片是重复显示的.其它2个就看不到.问题在什么地方
function Lodfiles()
{
var s=document.getElementById("Content").value;
if (s!="")
{
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>图片加载中...</option></select>";
var ImgWidth;
var ImgHeight;
var r=/<img[^>]+src=(\"|\'|)([^\"\'>]+)\1[^>]*>/gi;
var a=s.match(r);
var Img_url="";
if(a.length>0)
{
for(var i=0; i<a.length; i++)
{
r.test(a[i]);
var ImgObj=new Image();
ImgObj.src=RegExp.$2;
ImgWidth=ImgObj.width;//取得图片的宽度
ImgHeight=ImgObj.height; //取得图片的高度
ImgFileSize=Math.round(ImgObj.fileSize/1024*100)/100
if (ImgWidth>20&&ImgHeight>20&&ImgFileSize>1)
{
Img_url+="<option value="+RegExp.$2+">"+RegExp.$2+"</option>";
}
}
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>请选择图片</option>"+Img_url+"</select>";
}
else
{
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>新闻中没有图片</option></select>";
}
}
else
{
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>请先添加新闻内容</option></select>";
} }
function onchange_Img(va)
{
if (va!="")
{
document.getElementById("show_Img_list").innerHTML="<br><img src="+va+" />";
document.getElementById("set_index_img").value=va; }
else
{
document.getElementById("show_Img_list").innerHTML="";
document.getElementById("set_index_img").value="";
}
}
function Lodfiles()
{
var s=document.getElementById("Content").value;
if (s!="")
{
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>图片加载中...</option></select>";
var ImgWidth;
var ImgHeight;
var r=/<img[^>]+src=(\"|\'|)([^\"\'>]+)\1[^>]*>/gi;
var a=s.match(r);
var Img_url="";
if(a.length>0)
{
for(var i=0; i<a.length; i++)
{
r.test(a[i]);
var ImgObj=new Image();
ImgObj.src=RegExp.$2;
ImgWidth=ImgObj.width;//取得图片的宽度
ImgHeight=ImgObj.height; //取得图片的高度
ImgFileSize=Math.round(ImgObj.fileSize/1024*100)/100
if (ImgWidth>20&&ImgHeight>20&&ImgFileSize>1)
{
Img_url+="<option value="+RegExp.$2+">"+RegExp.$2+"</option>";
}
}
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>请选择图片</option>"+Img_url+"</select>";
}
else
{
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>新闻中没有图片</option></select>";
}
}
else
{
document.getElementById("list_option").innerHTML="<select id=\"Img_list\" onchange=\"onchange_Img(this.options[this.selectedIndex].value);\"><option>请先添加新闻内容</option></select>";
} }
function onchange_Img(va)
{
if (va!="")
{
document.getElementById("show_Img_list").innerHTML="<br><img src="+va+" />";
document.getElementById("set_index_img").value=va; }
else
{
document.getElementById("show_Img_list").innerHTML="";
document.getElementById("set_index_img").value="";
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货