Results 1 to 7 of 7

Thread: help with centering text in scroller

  1. #1
    Join Date
    May 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help with centering text in scroller

    "pausing Up and Down Scroller"
    http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

    I am trying to get the text in this scroller to align center instead of align left. I am new to java and am unable to see where I alter the code. Please help.

    Thanks. Amiwna

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Try this (red) in the style section of your page or if you have no style section create one in the head (red & blue):

    Code:
    <style type="text/css">
    #first2 {
    text-align:center;
    }
    #second2 {
    text-align:center;
    }
    </style>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thank you, but...

    Thank you for your assistance, however; that did not solve my problem. Everythign is still aligned left. Any other ideas?

    Thanks
    Amiwan

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I was so sure it would work that I just now tested it here locally and it works fine here in both IE6 and FF1.0.4, what browser are you using? I am assuming one of those or one that will behave like one of those in this situation so, if that's the case:

    PLEASE: Include the URL to your problematic webpage that you want help with.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    May 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well, I am obviously doing something wrong and would really appreciate the help. I haven't posted this site yet, so I have attached the html I am using. It is in an inline frame, however; that should not affect it should it? Again, I really appreciate the help. It doesn't seem like it should be this difficult, so I know that I am missing something. Thanks.



    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>PSW</title>

    <style type="text/css">
    #first2 {
    text-align:center;
    }
    #second2 {
    text-align:center;
    }
    </style>

    </head>

    <body>
    <script type="text/javascript">

    //configure the below five variables to change the style of the scroller
    var scrollerdelay='3000' //delay between msg scrolls. 3000=3 seconds.
    var scrollerwidth='100px'
    var scrollerheight='100px'
    var scrollerbgcolor='white'
    //set below to '' if you don't wish to use a background image
    var scrollerbackground=''

    //configure the below variable to change the contents of the scroller
    var messages=new Array()
    messages[0]="<font face='Papyrus'><a>Jim Champion - Realtor</a></font>"
    messages[1]="<font face='Papyrus'><a>Randy Selden - Realtor</a></font>"
    messages[2]="<font face='Papyrus'><a>Schwartz Vacations</a></font>"
    ///////Do not edit pass this line///////////////////////

    var ie=document.all
    var dom=document.getElementById

    if (messages.length>2)
    i=2
    else
    i=0

    function move(whichdiv){
    tdiv=eval(whichdiv)
    if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){
    tdiv.style.top=0+"px"
    setTimeout("move(tdiv)",scrollerdelay)
    setTimeout("move2(second2_obj)",scrollerdelay)
    return
    }
    if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
    tdiv.style.top=parseInt(tdiv.style.top)-5+"px"
    setTimeout("move(tdiv)",50)
    }
    else{
    tdiv.style.top=parseInt(scrollerheight)+"px"
    tdiv.innerHTML=messages[i]
    if (i==messages.length-1)
    i=0
    else
    i++
    }
    }

    function move2(whichdiv){
    tdiv2=eval(whichdiv)
    if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){
    tdiv2.style.top=0+"px"
    setTimeout("move2(tdiv2)",scrollerdelay)
    setTimeout("move(first2_obj)",scrollerdelay)
    return
    }
    if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
    tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"
    setTimeout("move2(second2_obj)",50)
    }
    else{
    tdiv2.style.top=parseInt(scrollerheight)+"px"
    tdiv2.innerHTML=messages[i]
    if (i==messages.length-1)
    i=0
    else
    i++
    }
    }

    function startscroll(){
    first2_obj=ie? first2 : document.getElementById("first2")
    second2_obj=ie? second2 : document.getElementById("second2")
    move(first2_obj)
    second2_obj.style.top=scrollerheight
    second2_obj.style.visibility='visible'
    }

    if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;background-color:'+scrollerbgcolor+' ;background-image:url('+scrollerbackground+')">')
    document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
    document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:1px;">')
    document.write(messages[0])
    document.writeln('</div>')
    document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px;visibility:hidden">')
    document.write(messages[dyndetermine=(messages.length==1)? 0 : 1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
    }

    if (window.addEventListener)
    window.addEventListener("load", startscroll, false)
    else if (window.attachEvent)
    window.attachEvent("onload", startscroll)
    else if (ie||dom)
    window.onload=startscroll

    </script>


    <p align="center">&nbsp;</p>


    </body>

    </html>

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I copied your code and the text was centered, I put it in an iframe, the text was centered. What html code and/or script and/or style are you using for your iframe?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    May 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thank you for your help and patience

    It did work. I did not use it correctly in my first attempt. I went back started from scratch and voila. It works. Thank you again. I appreciate all of the help.

    Amiwan

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •