jrjw
07-02-2008, 10:24 AM
I've got a bit of Javascript used to randomise an image on the front page of a website I've been working on. It works fine, but the default setting on IE (mine anyway) is to "restrict this webpage from running scripts or ActiveX controls that could access your computer" - so it returns a blank page until I click to "allow blocked content." I'm concerned potential visitors may have the same problem. Is there a better way to do what I want or can I change the code somehow? I don't see how generating a random number may harm my computer...
The code is:
<script type="text/javascript" language="JavaScript">
// Random Image Generator
NumberOfImagesToRotate = 8;
FirstPart = '<img src="images/splash';
LastPart = '.jpg" height="400" width="760" style="position: absolute; top: 90px; left: 0px;">';
function printImage() {
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.write(FirstPart + r + LastPart);
}
//-->
</script>
followed by:
<script type="text/javascript" language="JavaScript">
printImage();
</script>
I've tried the same thing in PHP which works ok, but it's not so easy to test or play around with (and I don't really know what I'm doing!). Any other ideas?
The code is:
<script type="text/javascript" language="JavaScript">
// Random Image Generator
NumberOfImagesToRotate = 8;
FirstPart = '<img src="images/splash';
LastPart = '.jpg" height="400" width="760" style="position: absolute; top: 90px; left: 0px;">';
function printImage() {
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.write(FirstPart + r + LastPart);
}
//-->
</script>
followed by:
<script type="text/javascript" language="JavaScript">
printImage();
</script>
I've tried the same thing in PHP which works ok, but it's not so easy to test or play around with (and I don't really know what I'm doing!). Any other ideas?