Javascript/ bilder som skifter [
Besvar ]
Av: Cecilie VÃ¥dahlJeg tenkte å ha et javascript på websiden som gjør at jeg kan ha flere logofelter på siden hvor hvert felt har flere logoer som det skiftes mellom, som på abc startsiden. Jeg har forsøkt med koden under. Jeg får det nederste feltet til å virke, men i det øverste feltet kommer det kun opp en logo. Hva kan være feil i koden?
Testsiden ligger her:
http://www.txvikings.com/test_index.html
<script language="JavaScript1.2">
var howOften = 5; //number often in seconds to rotate
var current = 0; //start the counter at 0
var ns6 = document.getElementById&&!document.all; //detect netscape 6
// place your images, text, etc in the array elements here
var items = new Array();
items[0]="<a href='http://www.nid.no' ><img alt='Norge i dag (9K)' src=' http://www.txvikings.com/nid.jpg' height='56' width='164'
border='0' /></a>"; //a linked image
items[1]="<a href='http://www.dagen.no'><img alt='image1 (9K)' src='http://www.txvikings.com/dagen.jpg' height='56' width='164'
border='0' /></a>"; //a linked image
items[2]="<a href='http://www.nid.no' ><img alt='Norge i dag (9K)' src=' http://www.txvikings.com/pizzabakern.gif' height='56' width='164'
border='0' /></a>"; //a linked image
items[3]="<a href='http://www.nid.no'><img alt='image1 (9K)' src='http://www.txvikings.com/xlbygg.png' height='56' width='164' border='0'
/></a>"; //a linked image
function rotater() {
document.getElementById("placeholder").innerHTML = items[current];
current = (current==items.length-1) ? 0 : current + 1;
setTimeout("rotater()",howOften*1000);
}
function rotater() {
if(document.layers) {
document.placeholderlayer.document.write(items[current]);
document.placeholderlayer.document.close();
}
if(ns6)document.getElementById("placeholderdiv").innerHTML=items[current]
if(document.all)
placeholderdiv.innerHTML=items[current];
current = (current==items.length-1) ? 0 : current + 1; //increment or reset
setTimeout("rotater()",howOften*1000);
}
window.onload=rotater;
//-->
</script>
<script language="JavaScript1.2">
var howOften = 5; //number often in seconds to rotate
var current = 0; //start the counter at 0
var ns6 = document.getElementById&&!document.all; //detect netscape 6
// place your images, text, etc in the array elements here
var items = new Array2();
items[0]="<a href='http://www.halsobolaget.no' ><img alt='Norge i dag (9K)' src=' http://www.txvikings.com/h_bolaget.jpg' height='56'
width='164' border='0' /></a>"; //a linked image
items[1]="<a href='http://www.dagen.no'><img alt='image1 (9K)' src='http://www.txvikings.com/dagen.jpg' height='56' width='164'
border='0' /></a>"; //a linked image
items[2]="<a href='http://www.nid.no' ><img alt='Norge i dag (9K)' src=' http://www.txvikings.com/pizzabakern.gif' height='56' width='164'
border='0' /></a>"; //a linked image
items[3]="<a href='http://www.nid.no'><img alt='image1 (9K)' src='http://www.txvikings.com/xlbygg.png' height='56' width='164' border='0'
/></a>"; //a linked image
function rotater() {
document.getElementById("placeholder").innerHTML = items[current];
current = (current==items.length-1) ? 0 : current + 1;
setTimeout("rotater()",howOften*1000);
}
function rotater() {
if(document.layers) {
document.placeholderlayer2.document.write(items[current]);
document.placeholderlayer2.document.close();
}
if(ns6)document.getElementById("placeholderdiv2").innerHTML=items[current]
if(document.all)
placeholderdiv2.innerHTML=items[current];
current = (current==items.length-1) ? 0 : current + 1; //increment or reset
setTimeout("rotater()",howOften*1000);
}
window.onload=rotater;
//-->
</script>
//Disse linjene har jeg der hvor logoene skal vises:
<layer id="placeholderlayer"></layer><div id="placeholderdiv"></div>
<layer id="placeholderlayer2"></layer><div id="placeholderdiv2">