Connecting Tech Pros Worldwide Help | Site Map

Accessible text scrolling don't work propely

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 18th, 2006, 12:15 PM
Satoshy
Guest
 
Posts: n/a
Default Accessible text scrolling don't work propely

Hi all,
i've implemented this text scroller from websemantics.co.uk (thanks to
Mike Foskett) but there are some problems with long's text.

There's an example here http://www.morrisonspub.it/new/scroller/

As you can see the text showed is not complete.. :(

How i can solve this problems?

This is the js code:

// Accessible Scroller by Mike Foskett
(http://www.websemantics.co.uk/). Retain this message and you may use
the code freely.

var speed=10 // speed of scroller
var step=3 // smoothness of movement
var top="#top" // name of anchor used as page top when clicking
start / stop / show
var Start= "Start" // Text for start link
var Stop = "Stop" // Text for stop link
var Show = "Show" // Text for show link

var x, scroll, divW, sText=""

function onclickIE(idAttr,handler,call){
if ((document.all)&&(document.getElementById)){idAttr[handler]=new
Function(call)}
}

function addLink(id,call,txt){
var e=document.createElement('A')
e.setAttribute('href',top)
e.setAttribute('onclick',call)
var linktext=document.createTextNode(txt)
e.appendChild(linktext)
document.getElementById(id).appendChild(e)
}

function addControls(){
addLink('controls','clickAction(0)',Stop)

onclickIE(document.getElementById('controls').chil dNodes[0],"onclick",'clickAction(0)')

document.getElementById('controls').appendChild(do cument.createTextNode('
| '))
addLink('controls','clickAction(2)',Show)

onclickIE(document.getElementById('controls').chil dNodes[2],"onclick",'clickAction(2)')
}

function stopScroller(){clearTimeout(scroll)}

function setAction(node,callvalue,txt){
var c=document.getElementById('controls')

c.childNodes[node].setAttribute('onclick','clickAction('+callvalue+' )')

onclickIE(document.getElementById('controls').chil dNodes[node],"onclick",'clickAction('+callvalue+')')
c.childNodes[node].firstChild.nodeValue=txt
}

function clickAction(no){
switch(no) {
case 0:
stopScroller()
setAction(0,1,Start)
setAction(2,2,Show)
break
case 1:
startScroller()
setAction(0,0,Stop)
setAction(2,2,Show)
break
case 2:
stopScroller()
setAction(0,1,Start)
setAction(2,3,Start)
x=0
document.getElementById('tag').style.whiteSpace='n ormal'
document.getElementById('tag').style.left='0px'
break
case 3:
startScroller()
setAction(0,0,Stop)
setAction(2,2,Show)
x=divW
document.getElementById('tag').style.left=x+'px'
}
}

function startScroller(){
document.getElementById('tag').style.whiteSpace='n owrap'
var p=document.createElement('P')
p.id='testP'
p.style.fontSize='25%' //fix for mozilla. multiply by 4 before using
x-=step
if (document.getElementById('tag').className)
p.className=document.getElementById('tag').classNa me
p.appendChild(document.createTextNode(sText))
document.body.appendChild(p)
pw=p.offsetWidth
document.body.removeChild(p)
if (x<(pw*4)*-1){x=divW}
document.getElementById('tag').style.left=x+'px'
scroll=setTimeout('startScroller()',speed)
}

function initScroller(){
if (document.getElementById && document.createElement &&
document.body.appendChild) {
addControls()
document.getElementById('controls').style.display= 'block'
divW=document.getElementById('scroller').offsetWid th
x=divW
document.getElementById('tag').style.position='rel ative'
document.getElementById('tag').style.left=divW+'px '
var ss=document.getElementById('tag').childNodes
for (i=0;i<ss.length;i++) {sText+=ss[i].nodeValue+" "}
scroll=setTimeout('startScroller()',speed)
}
}

function addLoadEvent(func) {
if (!document.getElementById | !document.getElementsByTagName) return
var oldonload = window.onload
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload()
func()
}
}
}

addLoadEvent(initScroller)


Thx a lot!

Satoshy


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.