0

I want to use javascript to look at a website. They have three images displaying depending on a certain status.

The other website uses an image tag <img src="http://website/123.png" id="ImageToDisplay">

There are two images and the image name changes for example: 111.png, 222.png.

So when they update there page to 222.png my website should pick it up and also show 222.png.

Using javascript I can imagine using getElementById("ImageToDisplay"), not sure how to pull from another website

I will be running the JavaScript with Classic ASP

user3588641
  • 21
  • 1
  • 5

2 Answers2

1

You can use Javascript's built-in functions:

function httpGet(theUrl)
{
    var xmlHttp = null;
    xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    return xmlHttp.responseText;
}

jQuery

$.get(
    "somepage.php",
    {paramOne : 1, paramX : 'abc'},
    function(data) {
       alert('page content: ' + data);
    }
);

If you are using asp.net you should take a look at the WebRequest Class here

Have fun !

d1rtyw0rm
  • 22
  • 4
-1

If you have CORS enabled, you can use AHAH to insert the code from that page into a <div> with style display:none;. You can then getElementById() and access its src property

AHAH example:

ahah('page.html','DivID');

Src Fetching Example

document.getElementById("img").src;

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
Deep
  • 920
  • 8
  • 22