Farah
01-28-2009, 08:28 PM
Hi,
Javascript is doing my head in because I can't seem to do the simplest thing such as the size of my images.
My javascript generates random images but I would like to restrict the size of these images to e.g. 350x350pixels.
Would really appereciate any help.
Here is the JS code.
EDITSorry If I've posted this in the wrong section
Is there anyways I can make these random images fluid because my whole website is fluid and would like them to be fluid when I resize the browser.
function onloadMLR()
{
// sets Interval of how often the function will run
window.setInterval("animateMLR()",1500);
}
function animateMLR()
{
var images = new Array();
images[0] = 'images2/hats/hats-1.jpg';
images[1] = 'images2/hats/hats-2.jpg';
images[2] = 'images2/hats/hats-3.jpg';
images[3] = 'images2/hats/hats-4.jpg';
images[4] = 'images2/hats/hats-5.jpg';
images[5] = 'images2/hats/hats-6.jpg';
images[6] = 'images2/hats/hats-7.jpg';
images[7] = 'images2/hats/hats-8.jpg';
images[8] = 'images2/hats/hats-9.jpg';
var randomImageIndex = Math.floor(Math.random() * images.length);
document.getElementById('divMLR').innerHTML='<img src="' + images[randomImageIndex] + '" />'
}
Javascript is doing my head in because I can't seem to do the simplest thing such as the size of my images.
My javascript generates random images but I would like to restrict the size of these images to e.g. 350x350pixels.
Would really appereciate any help.
Here is the JS code.
EDITSorry If I've posted this in the wrong section
Is there anyways I can make these random images fluid because my whole website is fluid and would like them to be fluid when I resize the browser.
function onloadMLR()
{
// sets Interval of how often the function will run
window.setInterval("animateMLR()",1500);
}
function animateMLR()
{
var images = new Array();
images[0] = 'images2/hats/hats-1.jpg';
images[1] = 'images2/hats/hats-2.jpg';
images[2] = 'images2/hats/hats-3.jpg';
images[3] = 'images2/hats/hats-4.jpg';
images[4] = 'images2/hats/hats-5.jpg';
images[5] = 'images2/hats/hats-6.jpg';
images[6] = 'images2/hats/hats-7.jpg';
images[7] = 'images2/hats/hats-8.jpg';
images[8] = 'images2/hats/hats-9.jpg';
var randomImageIndex = Math.floor(Math.random() * images.length);
document.getElementById('divMLR').innerHTML='<img src="' + images[randomImageIndex] + '" />'
}