lifeson
New Member
- Location
- Here or There but mainly Here
Anyone know any Javascript?
I have a bit of code that shows a random header image each time the page is refreshed...
<script language="JavaScript">
<!--
var str="";
var theImages = new Array() // do not change this
theImages[0] = '$BASE_PATH$/Backgrounds/header_1.png'
theImages[1] = '$BASE_PATH$/Backgrounds/header_2.png'
theImages[2] = '$BASE_PATH$/Backgrounds/header_3.png'
theImages[3] = '$BASE_PATH$/Backgrounds/header_5.jpg'
theImages[4] = '$BASE_PATH$/Backgrounds/header_7.jpg'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer = new Image()
preBuffer.src = theImages
}
var whichImage = Math.round(Math.random()*(p-1));
document.write('<div class="banners" style="text-align:center;"><img src="'+theImages[whichImage]+'"></div>');
//-->
</script>
The images are based on a screen resolution of 1280 px wide, the alternative images need to fit a browser width of 1024px
That works fine but I now want it to show a set of different images depending on the screen resolution. Is this possible?
I have a bit of code that shows a random header image each time the page is refreshed...
<script language="JavaScript">
<!--
var str="";
var theImages = new Array() // do not change this
theImages[0] = '$BASE_PATH$/Backgrounds/header_1.png'
theImages[1] = '$BASE_PATH$/Backgrounds/header_2.png'
theImages[2] = '$BASE_PATH$/Backgrounds/header_3.png'
theImages[3] = '$BASE_PATH$/Backgrounds/header_5.jpg'
theImages[4] = '$BASE_PATH$/Backgrounds/header_7.jpg'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer = new Image()
preBuffer.src = theImages
}
var whichImage = Math.round(Math.random()*(p-1));
document.write('<div class="banners" style="text-align:center;"><img src="'+theImages[whichImage]+'"></div>');
//-->
</script>
The images are based on a screen resolution of 1280 px wide, the alternative images need to fit a browser width of 1024px
That works fine but I now want it to show a set of different images depending on the screen resolution. Is this possible?