Scrolling News Line – Just one of MANY ways to do
There are many ways you can implement a scrolling news line on your site. This is just an example of one, but not the only way to do it. This is a good easy one to start with. Disclaimer: This is not my script but one I parsed together from 2 others I found.
- Add a Content Editor Web Part onto your page
- Modify the CEWP
- Edit the code below with your labels and URLs
- Copy and paste the code below into the CEWP Source Code Button.
- Click OK to save.
- Click OK to commit your changes to the page.
<DIV align=center>
<TABLE style="WIDTH: 90%" align=center summary="">
<TBODY>
<TR>
<TD><FONT color=#ff7200 size=2> </FONT>
<style type="text/css">
#memoryticker{
font: bold 12px Verdana;
color: ff7400;
background-color: white;
width: 600px;
height: 10px;
font: bold 12px Verdana;
color: ff7400;
text-align: center;
border: 0px solid orange;
padding: 1px;
/*0.9=0.9 seconds*/
filter: progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)
}
</style>
<script type="text/javascript">
//configure tickercontents[] to set the messages you to display
var tickercontents=new Array()
tickercontents[0]=' <a href=http://LindaChapman.BlogSpot.com/Lists/News/DispForm.aspx?ID=3>SharePoint News: </a>SharePoint Pro Connections</a>'
tickercontents[1]=' <a href=http://LindaChapman.BlogSPot.com/Lists/News/DispForm.aspx?ID=1>My News: </a>Nothing New</a>'
var persistlastviewedmsg=1 //should messages' order persist after users navigate away (1=yes, 0=no)?
var persistmsgbehavior="onload" //set to "onload" or "onclick".
//delay between messages (in miliseconds):
var tickdelay=3000
////Do not edit below////
var divonclick=(persistlastviewedmsg && persistmsgbehavior=="onclick")? 'onClick="savelastmsg()" ' : ''
var currentmessage=0
function changetickercontent(){
if (crosstick.filters && crosstick.filters.length>0)
crosstick.filters[0].Apply()
crosstick.innerHTML=tickercontents[currentmessage]
if (crosstick.filters && crosstick.filters.length>0)
crosstick.filters[0].Play()
currentmessage=(currentmessage==tickercontents.length-1)? currentmessage=0 : currentmessage+1
var filterduration=(crosstick.filters&&crosstick.filters.length>0)? crosstick.filters[0].duration*1000 : 0
setTimeout("changetickercontent()",tickdelay+filterduration)
}
function beginticker(){
if (persistlastviewedmsg && get_cookie("lastmsgnum")!="")
revivelastmsg()
crosstick=document.getElementById? document.getElementById("memoryticker") : document.all.memoryticker
changetickercontent()
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function savelastmsg(){
document.cookie="lastmsgnum="+currentmessage
}
function revivelastmsg(){
currentmessage=parseInt(get_cookie("lastmsgnum"))
currentmessage=(currentmessage==0)? tickercontents.length-1 : currentmessage-1
}
if (persistlastviewedmsg && persistmsgbehavior=="onload")
window.onunload=savelastmsg
if (document.all||document.getElementById)
document.write('<div id="memoryticker" '+divonclick+'></div>')
if (window.addEventListener)
window.addEventListener("load", beginticker, false)
else if (window.attachEvent)
window.attachEvent("onload", beginticker)
else if (document.all || document.getElementById)
window.onload=beginticker
</script>
</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
No comments:
Post a Comment