473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Problem with ticker

132 100+
Hi guys and girls,

I'm having trouble with a ticker that I'm making.

I've found code on the net and I'm adjusting it to my needs.
However though it seems to be working well I do have an issue.

If I have a long text which exceeds the width of my div, it won't show that text anymore.

I'm trying to fix it but it won't work.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <style type="text/css">
  4.  
  5. #tickercontainer
  6. {
  7. position: relative;
  8. width: 300px; /* width of the DIV containing the ticker */
  9. height: 19px; /* height of the DIV containing the ticker */
  10. background-color: white;
  11. background-image: url("bg.jpg");
  12. overflow: hidden;
  13. border: 0px solid black;
  14. padding: 2px;
  15. padding-left: 4px;
  16. }
  17.  
  18. #ticker
  19. {
  20. font-family: Tahoma;
  21. color: #ffffff;
  22. font-weight: bold;
  23. background-color: red;
  24. }
  25.  
  26. </style>
  27.  
  28. <script type="text/javascript">
  29.  
  30. var delay=0 //Specify the time (in milliseconds) you want to wait before the ticker starts (1000 = 1 seconds)
  31. var marqueespeed=1 //Specify the speed at which the ticker scrolls by (1:slow / 10:fast)
  32. var freeze=0 //Upon mouse over do you want to freeze the ticker so the user can click a link? (0:no / 1:yes)
  33.  
  34. var copyspeed=marqueespeed
  35. var pausespeed=(freeze==0)? copyspeed: 0
  36. var actualwidth=''
  37.  
  38. function scroll()
  39. {
  40.  
  41. if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
  42.     {
  43.         cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
  44.     }
  45. else
  46.     {
  47.         cross_marquee.style.left=parseInt(tickerwidth)+8+"px"
  48.     }
  49. }
  50.  
  51. function startticker()
  52. {
  53.  
  54. cross_marquee=document.getElementById("ticker")
  55. tickerwidth=document.getElementById("tickercontainer").offsetWidth
  56. cross_marquee.style.left= tickerwidth;
  57. actualwidth=cross_marquee.offsetWidth;
  58.  
  59. if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1)
  60.     { //if Opera or Netscape 7x, add scrollbars to scroll and exit
  61.         cross_marquee.style.height=marqueeheight+"px"
  62.         cross_marquee.style.overflow="scroll"
  63.         return
  64.     }
  65.  
  66. setTimeout('lefttime=setInterval("scroll()",30)', delay)
  67.  
  68. }
  69.  
  70. if (window.addEventListener)
  71. window.addEventListener("load", startticker, false)
  72. else if (window.attachEvent)
  73. window.attachEvent("onload", startticker)
  74. else if (document.getElementById)
  75. window.onload=startticker
  76.  
  77.  
  78. </script>
  79.  
  80. </head>
  81. <body>
  82.  
  83. <div id="tickercontainer" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">
  84. <div id="ticker" style="position: absolute; width: 98%;">
  85.  
  86. <!--SCROLL CONTENT HERE-->
  87.  
  88. Test 1 &nbsp;&nbsp;&nbsp; Test 2 &nbsp;&nbsp;&nbsp; Test 3 &nbsp;&nbsp;&nbsp; Test 4 &nbsp;&nbsp;&nbsp; 
  89.  
  90. <!--SCROLL CONTENT HERE-->
  91.  
  92. </div>
  93. </div>
  94. </body>
  95. </html>
  96.  
If you run this, you'll see that it works fine.
But if you adjust the width of "tickercontainer" (in the style at the top of the page) so for example 150px, you'll see that the text isn't being scrolled completely.

So I would like to have my text scrolled entirely. Who can help me with this?

Thanks,
Cainnech
Mar 30 '10 #1

✓ answered by RamananKalirajan

Hi cainnech,
I checked with your code. I can say why this problem occurs. The div with the id 'ticker' is given width: 98%. which takes the width from it parent div. It's parent Div is 'tickercontainer' which has a width 150px. So the child div (ticker) take 98% of the 150px width, thats why you get half content. Inorder to overcome this problem specify the width of the div 'ticker' to the content. Ex: for this text specify the width as '300px' you will be able to see the full content ticking in the div. Depending upon the content you are going to use set the width of the div 'ticker'.

Thanks and Regards
Ramanan Kalirajan

2 1818
RamananKalirajan
608 512MB
Hi cainnech,
I checked with your code. I can say why this problem occurs. The div with the id 'ticker' is given width: 98%. which takes the width from it parent div. It's parent Div is 'tickercontainer' which has a width 150px. So the child div (ticker) take 98% of the 150px width, thats why you get half content. Inorder to overcome this problem specify the width of the div 'ticker' to the content. Ex: for this text specify the width as '300px' you will be able to see the full content ticking in the div. Depending upon the content you are going to use set the width of the div 'ticker'.

Thanks and Regards
Ramanan Kalirajan
Mar 31 '10 #2
Cainnech
132 100+
Thanks RamananKalirajan for your reply.

However I can't specify the width of the text in de Ticker div because the text is being filled in dynamically.

I ended up writing the entire ticker myself. So now it works :-)

Greets,
Cainnech
Apr 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: RAD | last post by:
I am working with an evaluation copy of SQL Server 2000 for the first time; my DB experience lies with MS Access. I have a simple table in SQL Server (tblCompany) that has a field called...
4
by: dthelwal | last post by:
I'm looking for an applet or script to feed from an RSS page (perhaps RSS 0.91) and turn its <title> and <link> entries (perhaps using <description> as well) into a scrolling news ticker where the...
3
by: Dan | last post by:
Hi Does anyone know of a good Javascript typewriter ticker that allows you to insert HTML into the ticker. I have found lots but when HTML is inserted, the ticker pauses at the point it reaches...
4
by: Nariak | last post by:
Dear friends of programming! the script below only works with MSI and Opera but not with Netscape 7.x and Mozilla 1.x! What is wrong? Please help me! Thanks Ralf
1
by: Kaz | last post by:
Im creating a desktop ticker in C# that I wont to be displayed running along active applications, on the right hand side of the screen My question is that when I launch my ticker, how do i adjust...
1
by: David | last post by:
Hi, I have the following asp in my page, but I keep getting the following error Microsoft VBScript runtime error '800a0009' Subscript out of range: 'ticker' Please can you help me ?. Here...
2
by: swatidesai0407 | last post by:
hi,im working on tickers according to me whenever the stock becomes less than the minimum level the ticker should be generated. so i wrote a script using php to do dis.which is working fine....
5
by: =?Utf-8?B?SkF1bA==?= | last post by:
I am currently working on a project and need to get a return… even if that return is a failure. I must also add that I have no control over either the Regular Expression that will be used or the...
9
by: Mike | last post by:
I want to create a news/stock/sport ticker for my desktop. I want to have the ability to select my news source, (cnn, msnbc, etcs) sport source(espn, nfl, nba, etc) and my stock source (nasdaq,...
13
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.