使用 Javascript 进行幻灯片放映
我有一个使用 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>
I have a slide show using javascript where images display from another server (remote server). i have to display images from another server,problem is when i set "src" property of "Img" html tag, it append my server localhost path at starting as "http:\mysitehost.com\myremoresite.com\image1.jpg" where my image path is "http:\myremotesite.com\image1.jpg".
can any one tell me how to remove my site url "mysitehost.com" from the image path.
below is my 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 .src 属性中使用绝对路径时,应该不会有问题。
确保图像 URL 的格式以 **http://**myremotesite.com/image.jpg 开头。
When using an absolute path in the .src attribute, there should be not problems.
Make sure you format the image URL's starting with **http://**myremotesite.com/image.jpg.