gmask1
5th May 2005, 09:31 PM
I have made my very first widget - a simple image switcher, running from my site. It works beautifully in Safari, switching images and all. When I load it in Dashboard, two things happen:
1. It always (100% of the time) loads the first image in the array. Never any others.
2. Once it has loaded the first image the onclick function in the img tag works beautifully until the page refreshes, then it doesn't work at all. In other words, once the first image (which is always the same) is switched out for another image, the onclick call stops working!
Here comes the source for anyone watching - if anyone can help with my two problems, I'd be much obliged:
<head>
<meta http-equiv="Refresh" content="20; url=series1.html">
<script language="JavaScript">
function RandomizeImage()
{
var imagesarray = new Array("http://art.gmaskew.com/widget/s1_img1.jpg", "http://art.gmaskew.com/widget/s1_img2.jpg", "http://art.gmaskew.com/widget/s1_img3.jpg", "http://art.gmaskew.com/widget/s1_img4.jpg", "http://art.gmaskew.com/widget/s1_img5.jpg", "http://art.gmaskew.com/widget/s1_img6.jpg", "http://art.gmaskew.com/widget/s1_img7.jpg")
var randomnumber = Math.round(Math.random()*(imagesarray.length - 1))
document.images.mainlogo.src = imagesarray[randomnumber]
}
</script>
</head>
<html>
<body marginheight="0" marginwidth="0" onLoad="RandomizeImage();">
<img alt="HOME" name="mainlogo" width="323" height="216" id="mainlogo" onclick="widget.openURL('http://art.gmaskew.com')">
</body>
</html>
1. It always (100% of the time) loads the first image in the array. Never any others.
2. Once it has loaded the first image the onclick function in the img tag works beautifully until the page refreshes, then it doesn't work at all. In other words, once the first image (which is always the same) is switched out for another image, the onclick call stops working!
Here comes the source for anyone watching - if anyone can help with my two problems, I'd be much obliged:
<head>
<meta http-equiv="Refresh" content="20; url=series1.html">
<script language="JavaScript">
function RandomizeImage()
{
var imagesarray = new Array("http://art.gmaskew.com/widget/s1_img1.jpg", "http://art.gmaskew.com/widget/s1_img2.jpg", "http://art.gmaskew.com/widget/s1_img3.jpg", "http://art.gmaskew.com/widget/s1_img4.jpg", "http://art.gmaskew.com/widget/s1_img5.jpg", "http://art.gmaskew.com/widget/s1_img6.jpg", "http://art.gmaskew.com/widget/s1_img7.jpg")
var randomnumber = Math.round(Math.random()*(imagesarray.length - 1))
document.images.mainlogo.src = imagesarray[randomnumber]
}
</script>
</head>
<html>
<body marginheight="0" marginwidth="0" onLoad="RandomizeImage();">
<img alt="HOME" name="mainlogo" width="323" height="216" id="mainlogo" onclick="widget.openURL('http://art.gmaskew.com')">
</body>
</html>