Loading a different image on pageload?...Javascript array? Flash movies too? Oh my!
Dudes/Dudesses
I know next to nothing about Javascript, or web design in general, really, so please don't be offended if this seems a stupid or redundant question (!)...
...I've got the script for an image array, to load a different image each time the page loads...
...is it possible to alter this so that it will also load .swf movies as well as .gifs?
I tried changing the usual array listing e.g:
imageArray[1] = "images/image1.gif";
to, for example:
imageArray[1] = "images/flash1.swf";
...but, um - that doesn't work. At all. :eek:
If anyone can help in any way, I would really appreciate it. This may be a retarded question, but as previously, my knowledge level here is very basic.
As a guess, I'd say that this has something to do with either, or both, of these factors:
A) The array being titled 'image'Array - maybe it only recognizes images, and not movies (and I believe an .swf is classed as such).
B) The link to the .swf (e.g. "images/image.swf") does not contain the usual - longer-winded - code that helps the .swf load up (as you would get in html; <embed src> etc...). Maybe the question is, how to get all those details in the Javascript array itself...?
Many Thanks. Honestly, any help here is so appreciated. It may also save the computer from being physically harmed too.
Full script of the array in question follows....
:)
var imageArray = new Array();
imageArray[0] = "images/image.gif";
imageArray[1] = "images/image1.gif";
imageArray[2] = "images/image2.gif";
function doIt()
{
var rand = Math.floor(Math.random()*3);
var imgPath = "<img src='"+imageArray[rand]+"' alt='Welcome' border='0' align='absmiddle' />";
document.getElementById("image").innerHTML = imgPath;
}
:)