我有一个使用 javascript 的幻灯片放映,其中图像显示来自另一台服务器(远程服务器)。我必须显示来自另一台服务器的图像,问题是当我设置“Img”html标签的“src”属性时,它将我的服务器本地主机路径附加为“http:\mysitehost.com\myremoresite.com\image1.jpg”我的图像路径是“http:\myremotesite.com\image1.jpg”。谁能告诉我如何从图像路径中删除我的网站网址“mysitehost.com”。下面是我的javascript。
<script language="javascript" type="text/javascript">
var width = 283;
var height = 183;
var imgAr1 = new Array();
var rImg1 = new Array();
imgAr1[0] ='<%=url1%>'; // images comes from database with full imagepath like "http:remotesite.com\image.jpg"
imgAr1[1] = '<%= url1%>';
imgAr1[2] = '<%= url2%>';
imgAr1[3] = '<%= url3%>';
imgAr1[4] = '<%= url4%>';
imgAr1[5] = '<%= url5%>'; </script>
//to run slideshow
<script language="javascript" type="text/javascript">
//for(var j = 0; j < imgAr1.length; j++)
//{
// rImg1[j] = new Image();
// rImg1[j].src = imgAr1[j];
// alert(rImg1[j].src);
//}
document.onload = setting();
var slide;
function setting()
{
slide = document.getElementById('pic');
slide.setAttribute("src", imgAr1[0] );
slide.setAttribute("width",width);
slide.setAttribute("height",height);
setTimeout("", 5000);
slideshow();
}
//Image or picture slide show using java script
//slideshow function
var picture = 0;
function slideshow(){
if(picture < imgAr1.length-1){
picture=picture+1;
// slide.src = imgAr1[picture];
slide.setAttribute("src", imgAr1[picture]);
//alert(slide.src);
setTimeout("slideshow()", 5000);
}
else
{
picture = -1;
setTimeout("slideshow()", 5000);
}
}
</script>
//ASPX code
<div>
<img id="pic" border="0" style="z-index: 100" alt="Property Photo" title="Property Photo"/>
</div>