webmasterstuff: nieuwsticker

Je kunt stukjes nieuws laten invoeren via iframes of via speciale websites laten invullen. Er bestaan duizend en ייn manieren en dit is er ook eentje.
Een nieuwsticker die je op de pagina zelf invoert en via de bron updatet.

 
<body>

<script>

var text=new Array()
text[0]="hier komt je eerste berichtje"
text[1]="een tweede.."
text[2]="nummer3 laatste tekstje, tenzij je een volgend item toevoegt natuurlijk"



// verander hieronder de coresponderende websites 
// wil je geen link, zet er dan "#" neer ipv de website
var textlink=new Array()
textlink[0]="http://www.ducksite.be"
textlink[1]="#"
textlink[2]="index.html"


// bepaal hieronder waar de website geopent moet worden 
// kies uit "_blank", "_self", "_top" of de naam van je eigen frame
var texttarget=new Array()
texttarget[0]="_blank"
texttarget[1]="top"
texttarget[2]="menu"


// lettertype
var textfont="Georgia"

// letter kleur
var textfontcolor="#000000"

// letterkleur bij mouse-over
var textfontcolorrollover="#FF0000"

// grootte lettertype (CSS-values)
var textfontsize=10

// grootte lettertype 4x (HTML-values)
var textfontsizeHTML=4

// achtergrondkleur
var textbgcolor="#FFFFFF"

// weergaven lettertype (normal of bold)
var textweight="nomal"

// letterstyle (normal of italic)
var textitalic="normal"

// breedte tekstbox (pixels)
var textwidth=500

// hoogte telstbox (pixels)
var textheight=100

// pause tussen teksten (seconds)
var textpause=4

// breedte rand tekstvak
var textborder=0

// kleur van de rand
var textbordercolor="#0000CC"

// horizontale uitlijning teksten (center, left, right)
var textalign="left"

// verticale uitlijning (middle, top, bottom)
var textvalign="top"

onmouseover="this.stop()" 
onmouseout="this.start()"

// verander hieronder niets meer
var textdecoration="none"
var textweightA="<b>"
var textweightB="</b>"
var textitalicA=""
var textitalicB=""
var transparency=100
var transparencystep=2

var x_pos=0
var y_pos=0
var i_text=0
var textsplit=""
var i_textsplit=0
var i_mark=0
var tickercontent
var pausefade=30
textpause*=1000

var oneloopfinished=false

var browserinfos=navigator.userAgent 
var ie=document.all&&!browserinfos.match(/Opera/)
var ns4=document.layers
var ns6=document.getElementById&&!document.all&&!browserinfos.match(/Opera/)
var opera=browserinfos.match(/Opera/)  
var browserok=ie||ns4||ns6||opera

function changecontent() {
	getcontent()
	i_text++
	if (i_text>=text.length) {i_text=0}	
	if (ie) {
		ticker.innerHTML=content
		fadeout()
	}
	if (opera || ns6) {
		document.getElementById('ticker').innerHTML=content
		var texttimer=setTimeout("changecontent()",2*textpause)
	}
	if (ns4) {
		document.roof.document.ticker.document.write(content)
		document.roof.document.ticker.document.close()
		var texttimer=setTimeout("changecontent()",textpause)
	}	
}

function fadein() {
	if (transparency<100){
		transparency+=transparencystep
		if (ie) {
			document.all.tickerbg.filters.alpha.opacity=transparency
		}
		var fadetimer=setTimeout("fadein()",pausefade)
	}
	else {
		clearTimeout(fadetimer)
		setTimeout("changecontent()",1000)
	}
}

function fadeout() {
	if (transparency>0){
		transparency-=transparencystep
		if (ie) {
			document.all.tickerbg.filters.alpha.opacity=transparency
		}
		if (ns6) {
			document.getElementById('tickerbg').style.MozOpacity=transparency/100
		}
		var fadetimer=setTimeout("fadeout()",pausefade)
	}
	else {
		clearTimeout(fadetimer)
		setTimeout("fadein()",textpause)
	}
}

getcontent()
function getcontent() {
	if (ie || opera) {
		var tablewidth=textwidth-2*textborder
		var tableheight=textheight-2*textborder
	}
	else {
		var tablewidth=textwidth
		var tableheight=textheight
	}
	if (ie || ns6) {	
		var padding=parseInt(textborder)+3
		content="<table width="+tablewidth+" height="+tableheight+" cellpadding="+padding+" cellspacing=0 border=0><tr valign="+textvalign+"><td align="+textalign+">"
		content+="<a href=\""+textlink[i_text]+"\" target=\""+texttarget[i_text]+"\" style=\"position:relative;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";text-decoration:"+textdecoration+";color:"+textfontcolor+";font-style:"+textitalic+";\" onMouseOver=\"this.style.color=\'"+textfontcolorrollover+"\'\" onMouseOut=\"this.style.color=\'"+textfontcolor+"\'\">"
		content+=text[i_text]
		content+="</a></td></tr></table>"
	}
	else {	
		content="<table width="+tablewidth+" height="+tableheight+" cellpadding="+textborder+" cellspacing=0><tr valign="+textvalign+"><td align="+textalign+">"
		content+="<a href=\""+textlink[i_text]+"\" target=\""+texttarget[i_text]+"\" style=\"position:relative;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";text-decoration:"+textdecoration+";color:"+textfontcolor+";font-style:"+textitalic+";\">"
		content+=text[i_text]
		content+="</a></td></tr></table>"

		framecontent="<table width="+tablewidth+" height="+tableheight+" cellpadding=0 cellspacing=0 border="+textborder+"><tr><td>"
		framecontent+="<font color=\""+textbgcolor+"\">"
		framecontent+="."
		framecontent+="</font>"
		framecontent+="</td></tr></table>"
	}
}

if (ie || ns6 || opera) {
	if (ns6) {
		textwidth-=2*textborder
		textheight-=2*textborder
	}
	document.write("<div id=\"roof\" style=\"position:relative;width:"+textwidth+"px;height:"+textheight+"px;font-family:\'"+textfont+"\';border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;background-color:"+textbgcolor+";\">")
	
	if (!opera && !ns6 ) {
		document.write("<div id=\"tickerbg\" style=\"position:absolute;top:"+-textborder+"px;left:"+-textborder+"px;width:"+textwidth+"px;height:"+textheight+"px;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";font-style:"+textitalic+";border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;background-color:"+textfontcolor+";overflow:hidden\;filter:alpha(opacity=100)\">")
		document.write("</div>")
	}
	
	document.write("<div id=\"ticker\" style=\"position:absolute;top:"+-textborder+"px;left:"+-textborder+"px;width:"+textwidth+"px;height:"+textheight+"px;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";font-style:"+textitalic+";border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;overflow:hidden\;\">")
	document.write("</div></div>")

	window.onload=changecontent
}

else if (ns4) {
	document.write("<ilayer name=\"roof\" width="+textwidth+" height="+textheight+">")
		document.write("<layer name=\"tickerframe\" width="+textwidth+" height="+textheight+" top=0 left=0 bgcolor="+textbgcolor+">")
		document.write(framecontent)
		document.write("</layer>")
		document.write("<layer name=\"ticker\" width="+textwidth+" height="+textheight+" top=0 left=0>")
		document.write()
		document.write("</layer>")
	document.write("</ilayer>")
	window.onload=changecontent
}
</script>
</body>


Succes!