1

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>

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.