473,883 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript Code for Horizontal Scrolling Text

5 New Member
Hi ,

I need the Javascript code for Scrolling Horizontal Text instead of using the Marquee tag, as the Marquee tag is not supported by the Netscape Browser. Kindly Do help me out.

Regards
Smita
Nov 3 '08 #1
6 14995
acoder
16,027 Recognized Expert Moderator MVP
What have you managed or searched for so far?

The basics are setInterval (for timing) and the style.left property for setting the position.
Nov 3 '08 #2
balurajeev
7 New Member
Try this

I think this will help you


Expand|Select|Wrap|Line Numbers
  1. var l1 = 0; // Left of ticker In pixel, Or 0 To position relative
  2. var t1 = 0; // top of ticker In pixel, Or 0 To position relative
  3. var w1 = 400; // width of ticker In pixel
  4. var ie = document.all ? true : false;
  5. var first = true;
  6. var l2 = l1 + w1;
  7. var l3 = l1 - l2;
  8. var l = l2;
  9. var pos;
  10. function tickinit() {
  11. if(ie) {
  12. if(l1 == 0 && t1 == 0) {
  13. pos = document.all['tickpos'];
  14. l1 = getLeft(pos);
  15. t1 = getTop(pos);
  16. }
  17. ticktext.style.posTop = t1;
  18. }
  19. else {
  20. if(l1 == 0 && t1 == 0) {
  21. pos = document.anchors['tickpos'];
  22. l1 = pos.x;
  23. t1 = pos.y;
  24. }
  25. document.ticktext.pageY = t1;
  26. }
  27. l2 = l1 + w1;
  28. l3 = l1 - l2;
  29. l = l2;
  30. setInterval('tick()', 10);
  31. }
  32. function getLeft(ll) {
  33. if(ll.offsetParent)
  34. return (ll.offsetLeft + getLeft(ll.offsetParent));
  35. else
  36. return (ll.offsetLeft);
  37. }
  38. function getTop(ll) {
  39. if(ll.offsetParent)
  40. return (ll.offsetTop + getTop(ll.offsetParent));
  41. else
  42. return (ll.offsetTop);
  43. }
  44. function tick() {
  45. l = l - 0.5;
  46. if(l < l3) l = l2;
  47. cl = l1 - l;
  48. cr = l2 - l;
  49. if(ie) {
  50. ticktext.style.posLeft = l;
  51. ticktext.style.posTop = t1;
  52. ticktext.style.clip = "rect(auto "+cr+"px auto "+cl+"px)";
  53. if(first) ticktext.style.visibility = "visible";
  54. }
  55. else {
  56. document.ticktext.pageX = l;
  57. document.ticktext.clip.left = cl;
  58. document.ticktext.clip.right = cr;
  59. if(first) document.ticktext.visibility = "show";
  60. }
  61. first = false;
  62. }
  63.  
  64.  
  65. </script>
  66.  
  67. </head>
  68. <body onload="tickinit()">
  69.  
  70. <!-- STEP THREE: Copy this code into the BODY of your HTML document -->
  71.  
  72. <a name="tickpos"> </a>
  73.  
  74. <div id="ticktext" style="position:absolute;font-family:arial;font-size:14pt;visibility:hidden;">
  75. <nobr>Doesn't this message scroller look great? You can even insert links like this: <a href="http://www.yahoo.com" target="_blank">yahoo.com</a> Now it repeats.</nobr>
  76. </div>
  77. </body>
  78. </html>
Nov 3 '08 #3
smita232
5 New Member
Try this

I think this will help you


Expand|Select|Wrap|Line Numbers
  1. var l1 = 0; // Left of ticker In pixel, Or 0 To position relative
  2. var t1 = 0; // top of ticker In pixel, Or 0 To position relative
  3. var w1 = 400; // width of ticker In pixel
  4. var ie = document.all ? true : false;
  5. var first = true;
  6. var l2 = l1 + w1;
  7. var l3 = l1 - l2;
  8. var l = l2;
  9. var pos;
  10. function tickinit() {
  11. if(ie) {
  12. if(l1 == 0 && t1 == 0) {
  13. pos = document.all['tickpos'];
  14. l1 = getLeft(pos);
  15. t1 = getTop(pos);
  16. }
  17. ticktext.style.posTop = t1;
  18. }
  19. else {
  20. if(l1 == 0 && t1 == 0) {
  21. pos = document.anchors['tickpos'];
  22. l1 = pos.x;
  23. t1 = pos.y;
  24. }
  25. document.ticktext.pageY = t1;
  26. }
  27. l2 = l1 + w1;
  28. l3 = l1 - l2;
  29. l = l2;
  30. setInterval('tick()', 10);
  31. }
  32. function getLeft(ll) {
  33. if(ll.offsetParent)
  34. return (ll.offsetLeft + getLeft(ll.offsetParent));
  35. else
  36. return (ll.offsetLeft);
  37. }
  38. function getTop(ll) {
  39. if(ll.offsetParent)
  40. return (ll.offsetTop + getTop(ll.offsetParent));
  41. else
  42. return (ll.offsetTop);
  43. }
  44. function tick() {
  45. l = l - 0.5;
  46. if(l < l3) l = l2;
  47. cl = l1 - l;
  48. cr = l2 - l;
  49. if(ie) {
  50. ticktext.style.posLeft = l;
  51. ticktext.style.posTop = t1;
  52. ticktext.style.clip = "rect(auto "+cr+"px auto "+cl+"px)";
  53. if(first) ticktext.style.visibility = "visible";
  54. }
  55. else {
  56. document.ticktext.pageX = l;
  57. document.ticktext.clip.left = cl;
  58. document.ticktext.clip.right = cr;
  59. if(first) document.ticktext.visibility = "show";
  60. }
  61. first = false;
  62. }
  63.  
  64.  
  65. </script>
  66.  
  67. </head>
  68. <body onload="tickinit()">
  69.  
  70. <!-- STEP THREE: Copy this code into the BODY of your HTML document -->
  71.  
  72. <a name="tickpos"> </a>
  73.  
  74. <div id="ticktext" style="position:absolute;font-family:arial;font-size:14pt;visibility:hidden;">
  75. <nobr>Doesn't this message scroller look great? You can even insert links like this: <a href="http://www.yahoo.com" target="_blank">yahoo.com</a> Now it repeats.</nobr>
  76. </div>
  77. </body>
  78. </html>


Thanks for the reply... but am getting a horizontal scroll on the browser window.
Nov 3 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
Try this

I think this will help you
The script looks out-dated. There are better cross-browser scripts.
Nov 3 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Thanks for the reply... but am getting a horizontal scroll on the browser window.
So what did you want instead?
Nov 3 '08 #6
thimmappa
4 New Member
If you are trying to achive scrolling text through javaScript you can have a look at the free code provided at http://pc.byethost17.com/scripts/javascript/?id=54
Copy the code in your <script> tags in your HTML file and use the fucntion to call it using the function scroller = new Scroller(SCROLL ING_TEXT_ID, SLOWER_ID, FASTER_ID, CHANGE_DIRECTIO N_ID);
Sep 16 '10 #7

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

Similar topics

4
19581
by: mr_burns | last post by:
Hi, Is it possible to disble horizontal scrolling using CSS? I want to try and use two backgrounds, one tiling vertically and part of the body background, which will not force scrolling, but one that will be part of a table stretching of to the right, which will force unwanted horizontal scrolling. How is this written in the stylesheet? Cheers Burnsy
4
3802
by: anna | last post by:
How to tell if a horizontal scrollbar is present? I only want to use scrollTo if horizontal scrollbar is present. window.scrollbars.visibility doesn't specify which scrollbar is present, so it gives a false result if there is vertical scrollbar but not horizontal scrollbar. TIA, Anna
4
9675
by: D Newsham | last post by:
Hi, This javascript creates a table that has a header and side column that do not move while scrolling through the table. I need to convert this to vb script. Can anybody help, or do you have code in vb (asp) that would do the same thing? <html> <head> <title>Scrolling Grid Demo</title>
2
2678
by: Just D. | last post by:
Does anybody know how to disable the horizontal scrolling on ASPX form? What JAVA script should be used for that? The standard methods don't help and I'm looking for some JAVA function to fire it onscroll event to scroll the page back. Actually it's a bug of ASPX pages, we can disable the vertical scrolling but horizontal scrolling works if we try it with the touchpad. The only one possible solution I see is to use JAVA scripting. Just D.
14
12667
by: Karin Jensen | last post by:
Hi - I am trying to use Javascript to put material inside a table (i.e. alongside the previous material) if the user's screensize is big enough and outide the table (beneath table) if it isn't. The following code (tag properties and other extraneous material removed) works in IE but not Firefox: <table> <tr><td> first set of material </td>
3
3302
by: sumit | last post by:
Hi, I made a data grid vertically as well as horizontal scrollable as number of columns are very large!! But when i scroll horizontally then header is not visible as it also gets scrolled up,,so to tackle this i made a different data grid having only header as the row and the other datagrid contains the actual data for it,, Due to this vertical scrolling problem goes as i have put
0
1424
by: Dan Hinsley | last post by:
I just got one of the new Microsoft Mice that has a "tilt wheel" for horizontal scrolling. This works in a listbox in my VB.NET app, but doesn't work for a datagrid that does have a horizontal scroll bar. The same datagrid works with the wheel for vertical scrolling just fine. Is there something you have to do to catch the horizontal scroll events? Dan
4
2339
by: lmarceglia | last post by:
Hi, I have this website that doesn't work in Firefox 1.5: www.pianetaluca.com The HTML source is: <TITLE>PianetaLuca</TITLE> </HEAD>
3
5965
by: j0rd4n | last post by:
I have a user control that needs to allow vertical scrolling but not horizontal scrolling. In the user control's resize event, I need to adjust the size of all the children controls. For this to work correctly, I need the AutoScroll to not enable the horizontal scrollbar. After researching MSDN, I found the HScroll which can be used to disable horizontal scrolling when the AutoScroll mode is enabled. However, when I disable HScroll,...
0
9792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10847
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10415
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9573
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7971
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7126
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5797
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.