Hi,
I’m pretty new at javascript, xml etc.
So I was wondering if it is possible to create a XML file, with image links. And then load this links into a javascript array.
I’ve got this:
[CODE]
<script language=”javascript”>
<!–
var gallery = new Array();
[B]gallery[0] = new Array(
“http://www-tc.pbs.org/thewar/images/inline_pics/landing_at_war_03.jpg”,”http://www.spacetoday.org/images/SolSys/Earth/EarthBlueMarbleWestTerra.jpg”,
“http://content.answers.com/main/content/wp/en/thumb/a/a6/300px-Basic_human_anatomy_labeled.jpg”,
“http://static.howstuffworks.com/gif/green-beans-1.jpg”,”http://www.geekologie.com/2007/12/07/future-car-1.jpg”,
“http://www.afterdowningstreet.org/sites/afterdowningstreet.org/files/images/no_sleeping_hobo_5_430.thumbnail.jpg”
);[/B]
function pickImageFrom(whichGallery)
{
var idx = Math.floor(Math.random() * gallery[whichGallery].length);
document.write(‘<a href=”‘ + gallery[whichGallery][idx] + ‘” target=”_blank”><img src=”‘ + gallery[whichGallery][idx] + ‘” width=”50″ height=”50″></a>’);
}
//–>
</script>
I’d like not having to open this file each time I want to add an image. I’d like to do it in a pretty, clean, external XML file, or some other type of file… like a txt file where I’d simply add the links. I dunno. Anybody got a clue?
Thank you