Hallo!
ich würde gerne folgenden script für eine Bannerrotation nutzen und schaffe es nicht den Linkrahmen um die Bilder zu entfernen.
ich würde gerne folgenden script für eine Bannerrotation nutzen und schaffe es nicht den Linkrahmen um die Bilder zu entfernen.
Code:
<script type="text/javascript">
/**
* @banner [array] Bannersammlung
*/
var banner = new Array();
banner[0] = {
href: 'http://www.whatever.com',
src: 'banner0.gif',
alt: 'alttext 0'
}
banner[1] = {
href: 'http://www.whatever.com',
src: 'banner1.gif',
alt: 'alttext 1'
}
banner[2] = {
href: 'http://www.whatever.com',
src: 'banner2.gif',
alt: 'alttext 2'
}
banner[3] = {
href: 'http://www.whatever.com',
src: 'banner3.gif',
alt: 'alttext 3'
}
banner[4] = {
href: 'http://www.whatever.com',
src: 'banner4.gif',
alt: 'alttext 4'
}
banner[5] = {
href: 'http://www.whatever.com',
src: 'banner5.gif',
alt: 'alttext 5'
}
/**
* @bannerChange Gibt zufälligen Banner zurück [ html ]
* @param [string] id des banner-containers
* [array] die Bannersammlung
* [number] refresh in ms (optional)
*/
var bannerChange = {
init: function(zone,store,time){
this.name = 'bannerChange';
this.zone = document.getElementById(zone);
this.store = store;
this.count = store.length-1;
this.time = (time) ? time : false;
this.lastNr = null;
this.preloadImages();
this.randomShow();
if (this.time) this.interval = window.setInterval(this.name+".randomShow()", time);
},
preloadImages: function(){
for (var i=0;i<=this.count;i++) {
var img = new Image();
img.src = this.store[i].src;
}
},
getRandomNr: function(){
var nextNr;
do {
nextNr = Math.round(this.count * Math.random());
} while(nextNr == this.lastNr);
this.lastNr = nextNr;
return nextNr;
},
randomShow: function(){
var whichOne = this.getRandomNr();
var html = '<a href="'+this.store[whichOne].href+'" >';
html += '<img src="'+this.store[whichOne].src+'" ';
html += ' alt="'+this.store[whichOne].alt+'">';
html += '</a>';
this.zone.innerHTML = html;
}
}
window.onload = function(){
bannerChange.init('dropzone',banner,1000);
}
</script>
-------------------------------------
<div id="dropzone">
<!-- banner goes here -->
<a href="http://www.whatever.com">
<img src="banner0.gif" alt="banner für user ohne javascript" />
</a>
</div>